Example #1
0
 def _compute_anom_score(self, lag_window_points, point):
     """
 Compute anomaly score for a single data point.
 Anomaly score for a single data point(t,v) equals: abs(v - ema(lagging window)).
 :param list lag_window_points: values in the lagging window.
 :param float point: data point value.
 :return float: the anomaly score.
 """
     ema = utils.compute_ema(self.smoothing_factor, lag_window_points)[-1]
     return abs(point - ema)
Example #2
0
 def _compute_anom_score(self, lag_window_points, point):
   """
   Compute anomaly score for a single data point.
   Anomaly score for a single data point(t,v) equals: abs(v - ema(lagging window)).
   :param list lag_window_points: values in the lagging window.
   :param float point: data point value.
   :return float: the anomaly score.
   """
   ema = utils.compute_ema(self.smoothing_factor, lag_window_points)[-1]
   return abs(point - ema)
Example #3
0
 def _compute_anom_data_decay_all(self):
   """
   Compute anomaly scores using a lagging window covering all the data points before.
   """
   anom_scores = {}
   values = self.time_series.values
   ema = utils.compute_ema(self.smoothing_factor, values)
   stdev = numpy.std(values)
   for i, (timestamp, value) in enumerate(self.time_series_items):
     anom_score = abs((value - ema[i]) / stdev) if stdev else value - ema[i]
     anom_scores[timestamp] = anom_score
   self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))
Example #4
0
 def _compute_anom_data_decay_all(self):
     """
     Compute anomaly scores using a lagging window covering all the data points before.
     """
     anom_scores = {}
     values = self.time_series.values
     ema = utils.compute_ema(self.smoothing_factor, values)
     stdev = numpy.std(values)
     for i, (timestamp, value) in enumerate(self.time_series_items):
         anom_score = abs((value - ema[i]) / stdev) if stdev else value - ema[i]
         anom_scores[timestamp] = anom_score
     self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))
Example #5
0
 def _compute_anom_data_decay_all(self):
   """
   Compute anomaly scores using a lagging window covering all the data points before.
   """
   anom_scores = dict()
   values = self.time_series.values
   ema = utils.compute_ema(self.smoothing_factor, values)
   stdev = numpy.std(values)
   for (timestamp, value) in self.time_series.iteritems():
     index = self.time_series.timestamps.index(timestamp)
     anom_score = abs((value - ema[index]) / stdev) if stdev else value - ema[index]
     anom_scores[timestamp] = anom_score
   self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))
Example #6
0
 def _set_scores(self):
     """
 Compute anomaly scores for the time series.
 """
     anom_scores = {}
     self._compute_derivatives()
     derivatives_ema = utils.compute_ema(self.smoothing_factor, self.derivatives)
     for i, (timestamp, value) in enumerate(self.time_series_items):
         anom_scores[timestamp] = abs(self.derivatives[i] - derivatives_ema[i])
     stdev = numpy.std(anom_scores.values())
     if stdev:
         for timestamp in anom_scores.keys():
             anom_scores[timestamp] /= stdev
     self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))
Example #7
0
 def _set_scores(self):
     """
     Compute anomaly scores for the time series.
     """
     anom_scores = {}
     self._compute_derivatives()
     derivatives_ema = utils.compute_ema(self.smoothing_factor, self.derivatives)
     for i, (timestamp, value) in enumerate(self.time_series_items):
         anom_scores[timestamp] = abs(self.derivatives[i] - derivatives_ema[i])
     stdev = numpy.std(list(anom_scores.values()))
     if stdev:
             for timestamp in anom_scores.keys():
                 anom_scores[timestamp] /= stdev
     self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))
Example #8
0
 def _set_scores(self):
   """
   Compute anomaly scores for the time series.
   """
   anom_scores = dict()
   self._compute_derivatives()
   derivatives_ema = utils.compute_ema(self.smoothing_factor, self.derivatives)
   for (timestamp, value) in self.time_series.iteritems():
     index = self.time_series.timestamps.index(timestamp)
     anom_scores[timestamp] = abs(self.derivatives[index] - derivatives_ema[index])
   stdev = numpy.std(anom_scores.values())
   if stdev:
       for timestamp in anom_scores.keys():
         anom_scores[timestamp] /= stdev
   self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))