Exemple #1
0
 def __init__(self):
     self.iforest_obj = isolation_forest.IForest()
     self.ewma_obj = ewma.Ewma()
     self.polynomial_obj = polynomial_interpolation.PolynomialInterpolation(
     )
     self.statistic_obj = statistic.Statistic()
     self.supervised_obj = xgboosting.XGBoosting()
    def predict(self, X, window=DEFAULT_WINDOW):
        """
        Predict if a particular sample is an outlier or not.

        :param X: the time series to detect of
        :param type X: pandas.Series
        :param: window: the length of window
        :param type window: int
        :return: 1 denotes normal, 0 denotes abnormal
        """
        ewma_obj = ewma.Ewma(self.alpha, self.coefficient)
        ewma_ret = ewma_obj.predict(X)
        if ewma_ret == 1:
            result = 1
        else:
            polynomial_obj = polynomial_interpolation.PolynomialInterpolation(
                self.threshold, self.degree)
            polynomial_ret = polynomial_obj.predict(X, window)
            result = polynomial_ret
        return result