def _set_scores(self):
scores = np.zeros(len(self.time_series.values))<EOL>anomalies = SignTest._rolling_sign_test(self.scale * np.array(self.time_series.values),<EOL>self.scale * np.array(self.baseline_time_series.values),<EOL>k=self.scan_window,<EOL>conf=self.confidence,<EOL>alpha=float(self.percent_threshold) / <NUM_LIT:100>,<EOL>offset=self.scale * self.offset)<EOL>for (s, e), prob in anomalies:<EOL><INDENT>scores[s:e] = <NUM_LIT:100> * prob<EOL><DEDENT>scores_dict = dict()<EOL>for i, timestamp in enumerate(self.time_series.timestamps):<EOL><INDENT>scores_dict[timestamp] = scores[i]<EOL><DEDENT>self.anom_scores = TimeSeries(scores_dict)<EOL>
Compute anomaly scores for the time series
anomaly regions are computed with sign test which also assigns a likelihood
to the entire region