예제 #1
0
    def __init__(self,
                 time_series,
                 baseline_time_series,
                 percent_threshold_upper=None,
                 percent_threshold_lower=None,
                 offset=0.0,
                 scan_window=None,
                 confidence=0.01):
        """
        :param time_series: current time series
        :param baseline_time_series: baseline time series
        :param percent_threshold_upper: If time_series is larger than
            baseline_time_series by this percent, then its a candidate for an anomaly
        :param percent_threshold_lower: If time_series is smaller than
            baseline_time_series by this percent, then its a candidate for an
            anomaly. Percent_threshold_lower should be a negative number to work
            as intended.
        :param offset: baseline will be adjusted by this amount prior to
            computing percentage
            TimeSeries > offset +  (1 + percent_threshold_upper/100) * Baseline
            or for lower value TimeSeries < offset + (1 + percent_threshold_lower/100) * Baseline
        :param scan_window: number of data points to evaluate for anomalies
            default of 24 = 5 minute period for 2 hours
        :param confidence: Confidence to use for determining anomaly, default is 0.01
        :return:
        """
        super(SignTest, self).__init__(self.__class__.__name__, time_series,
                                       baseline_time_series)

        if percent_threshold_upper is None and percent_threshold_lower is None:
            raise exceptions.RequiredParametersNotPassed(
                'luminol.algorithms.anomaly_detector_algorithms.sign_test: \
                    Either percent_threshold_upper or percent_threshold_lower is needed'
            )

        if percent_threshold_upper is not None and percent_threshold_lower is not None:
            raise exceptions.RequiredParametersNotPassed(
                'luminol.algorithms.anomaly_detector_algorithms.sign_test: ' +
                'Cannot specify both percent_threshold_upper and percent_threshold_lower'
            )

        if not scan_window:
            raise exceptions.RequiredParametersNotPassed(
                'luminol.algorithms.anomaly_detector_algorithms.sign_test: ' +
                ' scan window size needs to be specified')

        # make assignements
        self.scan_window = scan_window
        self.confidence = confidence
        self.offset = offset

        self.percent_threshold = percent_threshold_upper if percent_threshold_upper is not None else percent_threshold_lower

        # scale will transform the time series and baseline
        # if we are detecting lower threshold we mirror the data
        self.scale = 1 if percent_threshold_upper is not None else -1
예제 #2
0
 def __init__(self, time_series, baseline_time_series, percent_threshold_upper=None, percent_threshold_lower=None):
     """
     :param time_series: current time series
     :param baseline_time_series: baseline time series
     :param percent_threshold_upper: If time_series is larger than
         baseline_time_series by this percent, then its an anomaly
     :param percent_threshold_lower: If time_series is smaller than
         baseline_time_series by this percent, then its an anomaly
     """
     super(DiffPercentThreshold, self).__init__(self.__class__.__name__, time_series, baseline_time_series)
     self.percent_threshold_upper = percent_threshold_upper
     self.percent_threshold_lower = percent_threshold_lower
     if not self.percent_threshold_upper and not self.percent_threshold_lower:
         raise exceptions.RequiredParametersNotPassed(
             'luminol.algorithms.anomaly_detector_algorithms.diff_percent_threshold: ' +
             'Either percent_threshold_upper or percent_threshold_lower needed')
예제 #3
0
  def __init__(self, time_series, absolute_threshold_value_upper=None, absolute_threshold_value_lower=None,
               baseline_time_series=None):
    """
    Initialize algorithm, check all required args are present

    :param time_series: The current time series dict to run anomaly detection on
    :param absolute_threshold_value_upper: Time series values above this are considered anomalies
    :param absolute_threshold_value_lower: Time series values below this are considered anomalies
    :param baseline_time_series: A no-op for now
    :return:
    """
    super(AbsoluteThreshold, self).__init__(self.__class__.__name__, time_series, baseline_time_series)
    self.absolute_threshold_value_upper = absolute_threshold_value_upper
    self.absolute_threshold_value_lower = absolute_threshold_value_lower
    if not self.absolute_threshold_value_lower and not self.absolute_threshold_value_upper:
      raise exceptions.RequiredParametersNotPassed('luminol.algorithms.anomaly_detector_algorithms.absolute_threshold: '
                                                   'Either absolute_threshold_value_upper or '
                                                   'absolute_threshold_value_lower needed')