Search in sources :

Example 1 with TransformationFunction

use of com.linkedin.thirdeye.anomalydetection.model.transform.TransformationFunction in project pinot by linkedin.

the class MinMaxThresholdFunction method init.

@Override
public void init(AnomalyFunctionDTO spec) throws Exception {
    super.init(spec);
    // Removes zeros from time series, which currently mean empty values in ThirdEye.
    TransformationFunction zeroRemover = new ZeroRemovalFunction();
    currentTimeSeriesTransformationChain.add(zeroRemover);
    detectionModel = new MinMaxThresholdDetectionModel();
    detectionModel.init(properties);
    mergeModel = new MinMaxThresholdMergeModel();
    mergeModel.init(properties);
}
Also used : ZeroRemovalFunction(com.linkedin.thirdeye.anomalydetection.model.transform.ZeroRemovalFunction) MinMaxThresholdMergeModel(com.linkedin.thirdeye.anomalydetection.model.merge.MinMaxThresholdMergeModel) MinMaxThresholdDetectionModel(com.linkedin.thirdeye.anomalydetection.model.detection.MinMaxThresholdDetectionModel) TransformationFunction(com.linkedin.thirdeye.anomalydetection.model.transform.TransformationFunction)

Example 2 with TransformationFunction

use of com.linkedin.thirdeye.anomalydetection.model.transform.TransformationFunction in project pinot by linkedin.

the class WeekOverWeekRuleFunction method init.

public void init(Properties properties) {
    this.properties = properties;
    String baselineProp = this.properties.getProperty(BASELINE);
    if (StringUtils.isNotBlank(baselineProp)) {
        this.initPropertiesForDataModel(baselineProp);
    }
    dataModel = new SeasonalDataModel();
    dataModel.init(this.properties);
    // Removes zeros from time series, which currently mean empty values in ThirdEye.
    TransformationFunction zeroRemover = new ZeroRemovalFunction();
    currentTimeSeriesTransformationChain.add(zeroRemover);
    baselineTimeSeriesTransformationChain.add(zeroRemover);
    // Add total count threshold transformation
    if (this.properties.containsKey(TotalCountThresholdRemovalFunction.TOTAL_COUNT_METRIC_NAME)) {
        TransformationFunction totalCountThresholdFunction = new TotalCountThresholdRemovalFunction();
        totalCountThresholdFunction.init(this.properties);
        currentTimeSeriesTransformationChain.add(totalCountThresholdFunction);
    }
    // Add moving average smoothing transformation
    if (this.properties.containsKey(ENABLE_SMOOTHING)) {
        TransformationFunction movingAverageSoothingFunction = new MovingAverageSmoothingFunction();
        movingAverageSoothingFunction.init(this.properties);
        currentTimeSeriesTransformationChain.add(movingAverageSoothingFunction);
        baselineTimeSeriesTransformationChain.add(movingAverageSoothingFunction);
    }
    predictionModel = new SeasonalAveragePredictionModel();
    predictionModel.init(this.properties);
    detectionModel = new SimpleThresholdDetectionModel();
    detectionModel.init(this.properties);
    mergeModel = new SimplePercentageMergeModel();
    mergeModel.init(this.properties);
}
Also used : SimplePercentageMergeModel(com.linkedin.thirdeye.anomalydetection.model.merge.SimplePercentageMergeModel) ZeroRemovalFunction(com.linkedin.thirdeye.anomalydetection.model.transform.ZeroRemovalFunction) SeasonalAveragePredictionModel(com.linkedin.thirdeye.anomalydetection.model.prediction.SeasonalAveragePredictionModel) SeasonalDataModel(com.linkedin.thirdeye.anomalydetection.model.data.SeasonalDataModel) MovingAverageSmoothingFunction(com.linkedin.thirdeye.anomalydetection.model.transform.MovingAverageSmoothingFunction) SimpleThresholdDetectionModel(com.linkedin.thirdeye.anomalydetection.model.detection.SimpleThresholdDetectionModel) TransformationFunction(com.linkedin.thirdeye.anomalydetection.model.transform.TransformationFunction) TotalCountThresholdRemovalFunction(com.linkedin.thirdeye.anomalydetection.model.transform.TotalCountThresholdRemovalFunction)

Example 3 with TransformationFunction

use of com.linkedin.thirdeye.anomalydetection.model.transform.TransformationFunction in project pinot by linkedin.

the class AbstractModularizedAnomalyFunction method transformTimeSeries.

/**
   * Transform the current time series and baselines.
   *
   * TODO: Apply Chain-of-Responsibility on the transformation chain
   *
   * @param metricName the name of the metric on which we apply transformation and prediction
   * @param anomalyDetectionContext anomaly detection context that contains the time series to be
   *                                transformed.
   */
private void transformTimeSeries(String metricName, AnomalyDetectionContext anomalyDetectionContext) {
    // Transform the observed (current) time series
    if (anomalyDetectionContext.getTransformedCurrent(metricName) == null) {
        anomalyDetectionContext.setTransformedCurrent(metricName, anomalyDetectionContext.getCurrent(metricName));
    }
    List<TransformationFunction> currentTimeSeriesTransformationChain = getCurrentTimeSeriesTransformationChain();
    if (CollectionUtils.isNotEmpty(currentTimeSeriesTransformationChain)) {
        for (TransformationFunction tf : currentTimeSeriesTransformationChain) {
            anomalyDetectionContext.setTransformedCurrent(metricName, tf.transform(anomalyDetectionContext.getTransformedCurrent(metricName), anomalyDetectionContext));
        }
    }
    // Transform baseline time series
    if (anomalyDetectionContext.getTransformedBaselines(metricName) == null) {
        anomalyDetectionContext.setTransformedBaselines(metricName, anomalyDetectionContext.getBaselines(metricName));
    }
    List<TransformationFunction> baselineTimeSeriesTransformationChain = getBaselineTimeSeriesTransformationChain();
    if (CollectionUtils.isNotEmpty(anomalyDetectionContext.getTransformedBaselines(metricName)) && CollectionUtils.isNotEmpty(baselineTimeSeriesTransformationChain)) {
        for (TransformationFunction tf : baselineTimeSeriesTransformationChain) {
            List<TimeSeries> transformedBaselines = new ArrayList<>();
            for (TimeSeries ts : anomalyDetectionContext.getTransformedBaselines(metricName)) {
                TimeSeries transformedTS = tf.transform(ts, anomalyDetectionContext);
                transformedBaselines.add(transformedTS);
            }
            anomalyDetectionContext.setTransformedBaselines(metricName, transformedBaselines);
        }
    }
}
Also used : TimeSeries(com.linkedin.thirdeye.anomalydetection.context.TimeSeries) MetricTimeSeries(com.linkedin.thirdeye.api.MetricTimeSeries) ArrayList(java.util.ArrayList) TransformationFunction(com.linkedin.thirdeye.anomalydetection.model.transform.TransformationFunction)

Aggregations

TransformationFunction (com.linkedin.thirdeye.anomalydetection.model.transform.TransformationFunction)3 ZeroRemovalFunction (com.linkedin.thirdeye.anomalydetection.model.transform.ZeroRemovalFunction)2 TimeSeries (com.linkedin.thirdeye.anomalydetection.context.TimeSeries)1 SeasonalDataModel (com.linkedin.thirdeye.anomalydetection.model.data.SeasonalDataModel)1 MinMaxThresholdDetectionModel (com.linkedin.thirdeye.anomalydetection.model.detection.MinMaxThresholdDetectionModel)1 SimpleThresholdDetectionModel (com.linkedin.thirdeye.anomalydetection.model.detection.SimpleThresholdDetectionModel)1 MinMaxThresholdMergeModel (com.linkedin.thirdeye.anomalydetection.model.merge.MinMaxThresholdMergeModel)1 SimplePercentageMergeModel (com.linkedin.thirdeye.anomalydetection.model.merge.SimplePercentageMergeModel)1 SeasonalAveragePredictionModel (com.linkedin.thirdeye.anomalydetection.model.prediction.SeasonalAveragePredictionModel)1 MovingAverageSmoothingFunction (com.linkedin.thirdeye.anomalydetection.model.transform.MovingAverageSmoothingFunction)1 TotalCountThresholdRemovalFunction (com.linkedin.thirdeye.anomalydetection.model.transform.TotalCountThresholdRemovalFunction)1 MetricTimeSeries (com.linkedin.thirdeye.api.MetricTimeSeries)1 ArrayList (java.util.ArrayList)1