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 2020/10/15 02:52:04 UTC

[GitHub] [incubator-pinot] bryantachen commented on a change in pull request #6101: [TE] web-api - endpoint for getting performance metrics of detection …

bryantachen commented on a change in pull request #6101:
URL: https://github.com/apache/incubator-pinot/pull/6101#discussion_r505133609



##########
File path: thirdeye/thirdeye-spi/src/main/java/org/apache/pinot/thirdeye/detection/performance/PerformanceMetrics.java
##########
@@ -0,0 +1,136 @@
+package org.apache.pinot.thirdeye.detection.performance;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+
+/**
+ * The performance metrics of a detection based on the given anomalies
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class PerformanceMetrics {
+
+  @JsonProperty
+  private PerformanceMetric totalAnomalies;
+
+  @JsonProperty
+  private PerformanceMetric responseRate;
+
+  @JsonProperty
+  private PerformanceMetric precision;
+
+  @JsonProperty
+  private PerformanceMetric recall;
+
+  public PerformanceMetric getTotalAnomalies() { return totalAnomalies; }
+
+  public PerformanceMetric getResponseRate() { return responseRate; }
+
+  public PerformanceMetric getPrecision() { return precision; }
+
+  public PerformanceMetric getRecall() { return recall; }
+
+  /**
+   * Builder for performance metrics
+   */
+  public static class Builder {
+    private long respondedAnomalies, truePos, falsePos, falseNeg, numAnomalies = 0L;
+    private boolean includeTotalAnomalies, includeResponseRate, includePrecision, includeRecall = false;
+    private final String NOT_CLASSIFIED = "NONE";
+    private final String TRUE_POSITIVE = "TRUE_POSITIVE";
+    private final String FALSE_POSITIVE = "FALSE_POSITIVE";
+    private final String FALSE_NEGATIVE = "FALSE_NEGATIVE";
+
+    public Builder (List<String> statusClassifications) {
+      statusClassifications.stream()
+          .forEach(classification -> {
+            this.numAnomalies++;
+            if (!classification.equals(NOT_CLASSIFIED)) {

Review comment:
       consider (!NOT_CLASSIFIED.equals(classification)) to avoid possible NPE




----------------------------------------------------------------
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



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