|
@@ -7,6 +7,7 @@
|
|
|
|
|
|
package org.elasticsearch.xpack.core.ml.job.results;
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.Writeable;
|
|
@@ -31,6 +32,7 @@ public class AnomalyScoreExplanation implements ToXContentObject, Writeable {
|
|
|
public static final ParseField UPPER_CONFIDENCE_BOUND = new ParseField("upper_confidence_bound");
|
|
|
public static final ParseField HIGH_VARIANCE_PENALTY = new ParseField("high_variance_penalty");
|
|
|
public static final ParseField INCOMPLETE_BUCKET_PENALTY = new ParseField("incomplete_bucket_penalty");
|
|
|
+ public static final ParseField MULTIMODAL_DISTRIBUTION = new ParseField("multimodal_distribution");
|
|
|
|
|
|
public static final ObjectParser<AnomalyScoreExplanation, Void> STRICT_PARSER = createParser(false);
|
|
|
public static final ObjectParser<AnomalyScoreExplanation, Void> LENIENT_PARSER = createParser(true);
|
|
@@ -51,6 +53,7 @@ public class AnomalyScoreExplanation implements ToXContentObject, Writeable {
|
|
|
parser.declareDouble(AnomalyScoreExplanation::setUpperConfidenceBound, UPPER_CONFIDENCE_BOUND);
|
|
|
parser.declareBoolean(AnomalyScoreExplanation::setHighVariancePenalty, HIGH_VARIANCE_PENALTY);
|
|
|
parser.declareBoolean(AnomalyScoreExplanation::setIncompleteBucketPenalty, INCOMPLETE_BUCKET_PENALTY);
|
|
|
+ parser.declareBoolean(AnomalyScoreExplanation::setMultimodalDistribution, MULTIMODAL_DISTRIBUTION);
|
|
|
return parser;
|
|
|
}
|
|
|
|
|
@@ -64,6 +67,7 @@ public class AnomalyScoreExplanation implements ToXContentObject, Writeable {
|
|
|
private Double upperConfidenceBound;
|
|
|
private Boolean highVariancePenalty;
|
|
|
private Boolean incompleteBucketPenalty;
|
|
|
+ private Boolean multimodalDistribution;
|
|
|
|
|
|
AnomalyScoreExplanation() {}
|
|
|
|
|
@@ -78,6 +82,9 @@ public class AnomalyScoreExplanation implements ToXContentObject, Writeable {
|
|
|
this.upperConfidenceBound = in.readOptionalDouble();
|
|
|
this.highVariancePenalty = in.readOptionalBoolean();
|
|
|
this.incompleteBucketPenalty = in.readOptionalBoolean();
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_8_7_0)) {
|
|
|
+ this.multimodalDistribution = in.readOptionalBoolean();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -92,6 +99,9 @@ public class AnomalyScoreExplanation implements ToXContentObject, Writeable {
|
|
|
out.writeOptionalDouble(upperConfidenceBound);
|
|
|
out.writeOptionalBoolean(highVariancePenalty);
|
|
|
out.writeOptionalBoolean(incompleteBucketPenalty);
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_8_7_0)) {
|
|
|
+ out.writeOptionalBoolean(multimodalDistribution);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -127,6 +137,9 @@ public class AnomalyScoreExplanation implements ToXContentObject, Writeable {
|
|
|
if (incompleteBucketPenalty != null) {
|
|
|
builder.field(INCOMPLETE_BUCKET_PENALTY.getPreferredName(), incompleteBucketPenalty);
|
|
|
}
|
|
|
+ if (multimodalDistribution != null) {
|
|
|
+ builder.field(MULTIMODAL_DISTRIBUTION.getPreferredName(), multimodalDistribution);
|
|
|
+ }
|
|
|
builder.endObject();
|
|
|
return builder;
|
|
|
}
|
|
@@ -143,7 +156,8 @@ public class AnomalyScoreExplanation implements ToXContentObject, Writeable {
|
|
|
typicalValue,
|
|
|
upperConfidenceBound,
|
|
|
highVariancePenalty,
|
|
|
- incompleteBucketPenalty
|
|
|
+ incompleteBucketPenalty,
|
|
|
+ multimodalDistribution
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -166,7 +180,8 @@ public class AnomalyScoreExplanation implements ToXContentObject, Writeable {
|
|
|
&& Objects.equals(this.typicalValue, that.typicalValue)
|
|
|
&& Objects.equals(this.upperConfidenceBound, that.upperConfidenceBound)
|
|
|
&& Objects.equals(this.highVariancePenalty, that.highVariancePenalty)
|
|
|
- && Objects.equals(this.incompleteBucketPenalty, that.incompleteBucketPenalty);
|
|
|
+ && Objects.equals(this.incompleteBucketPenalty, that.incompleteBucketPenalty)
|
|
|
+ && Objects.equals(this.multimodalDistribution, that.multimodalDistribution);
|
|
|
}
|
|
|
|
|
|
public String getAnomalyType() {
|
|
@@ -249,4 +264,12 @@ public class AnomalyScoreExplanation implements ToXContentObject, Writeable {
|
|
|
this.incompleteBucketPenalty = incompleteBucketPenalty;
|
|
|
}
|
|
|
|
|
|
+ public Boolean isMultimodalDistribution() {
|
|
|
+ return multimodalDistribution;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setMultimodalDistribution(Boolean multimodalDistribution) {
|
|
|
+ this.multimodalDistribution = multimodalDistribution;
|
|
|
+ }
|
|
|
+
|
|
|
}
|