You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2019/04/29 23:35:58 UTC

[GitHub] [incubator-pinot] xiaohui-sun commented on a change in pull request #4176: [TE] anomaly detector interface change and implementation for rule-based detection

xiaohui-sun commented on a change in pull request #4176: [TE] anomaly detector interface change and implementation for rule-based detection
URL: https://github.com/apache/incubator-pinot/pull/4176#discussion_r279575775
 
 

 ##########
 File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/components/ThresholdRuleDetector.java
 ##########
 @@ -87,8 +91,38 @@
     df.mapInPlace(BooleanSeries.HAS_TRUE, COL_ANOMALY, COL_TOO_HIGH, COL_TOO_LOW);
 
     DatasetConfigDTO datasetConfig = data.getDatasetForMetricId().get(me.getId());
-    return DetectionUtils.makeAnomalies(slice, df, COL_ANOMALY, endTime,
+    List<MergedAnomalyResultDTO> anomalies = DetectionUtils.makeAnomalies(slice, df, COL_ANOMALY, endTime,
         DetectionUtils.getMonitoringGranularityPeriod(monitoringGranularity, datasetConfig), datasetConfig);
+    return DetectionResult.from(anomalies, TimeSeries.fromDataFrame(constructThresholdBoundaries(df)));
+  }
+
+  @Override
+  public TimeSeries computePredictedTimeSeries(MetricSlice slice) {
+    InputData data =
+        this.dataFetcher.fetchData(new InputDataSpec().withTimeseriesSlices(Collections.singletonList(slice)));
+    DataFrame df = data.getTimeseries().get(slice);
+    return TimeSeries.fromDataFrame(constructThresholdBoundaries(df));
+  }
+
+  private DataFrame constructThresholdBoundaries(DataFrame df) {
+    if (!Double.isNaN(this.min)) {
+      df.addSeries(COL_LOWER_BOUND, DoubleSeries.fillValues(df.size(), this.min));
+    }
+    if (!Double.isNaN(this.max)) {
+      df.addSeries(COL_UPPER_BOUND, DoubleSeries.fillValues(df.size(), this.max));
+    }
+    df.addSeries(COL_VALUE, DoubleSeries.fillValues(df.size(), predictedValue()));
+    return df;
+  }
+
+  private double predictedValue() {
 
 Review comment:
   There should be no predicted value (or the predicted value is the current value) for threshold based detector.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org