def _set_scores(self):
anom_scores = {}<EOL>self._compute_derivatives()<EOL>derivatives_ema = utils.compute_ema(self.smoothing_factor, self.derivatives)<EOL>for i, (timestamp, value) in enumerate(self.time_series_items):<EOL><INDENT>anom_scores[timestamp] = abs(self.derivatives[i] - derivatives_ema[i])<EOL><DEDENT>stdev = numpy.std(list(anom_scores.values()))<EOL>if stdev:<EOL><INDENT>for timestamp in anom_scores.keys():<EOL><INDENT>anom_scores[timestamp] /= stdev<EOL><DEDENT><DEDENT>self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))<EOL>
Compute anomaly scores for the time series.