Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MA] Updating models Ctrs to take required args #22593

Merged
merged 5 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions sdk/metricsadvisor/azure-ai-metricsadvisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ DataFeed dataFeed = new DataFeed()
.setGranularity(new DataFeedGranularity().setGranularityType(DataFeedGranularityType.DAILY))
.setSchema(new DataFeedSchema(
Arrays.asList(
new DataFeedMetric().setName("cost"),
new DataFeedMetric().setName("revenue")
new DataFeedMetric("cost"),
new DataFeedMetric("revenue")
)).setDimensions(
Arrays.asList(
new DataFeedDimension().setName("city"),
new DataFeedDimension().setName("category")
new DataFeedDimension("city"),
new DataFeedDimension("category")
))
)
.setIngestionSettings(new DataFeedIngestionSettings(OffsetDateTime.parse("2020-01-01T00:00:00Z")))
Expand Down Expand Up @@ -239,22 +239,22 @@ This example demonstrates how a user can configure an anomaly detection configur
```java
String metricId = "3d48er30-6e6e-4391-b78f-b00dfee1e6f5";

ChangeThresholdCondition changeThresholdCondition = new ChangeThresholdCondition()
.setAnomalyDetectorDirection(AnomalyDetectorDirection.BOTH)
.setChangePercentage(20)
.setShiftPoint(10)
.setWithinRange(true)
.setSuppressCondition(new SuppressCondition().setMinNumber(1).setMinRatio(2));

HardThresholdCondition hardThresholdCondition = new HardThresholdCondition()
.setAnomalyDetectorDirection(AnomalyDetectorDirection.DOWN)
.setLowerBound(5.0)
.setSuppressCondition(new SuppressCondition().setMinNumber(1).setMinRatio(1));

SmartDetectionCondition smartDetectionCondition = new SmartDetectionCondition()
.setAnomalyDetectorDirection(AnomalyDetectorDirection.UP)
.setSensitivity(10.0)
.setSuppressCondition(new SuppressCondition().setMinNumber(1).setMinRatio(2));
ChangeThresholdCondition changeThresholdCondition = new ChangeThresholdCondition(
20,
10,
true,
AnomalyDetectorDirection.BOTH,
new SuppressCondition(1, 2));

HardThresholdCondition hardThresholdCondition = new HardThresholdCondition(
AnomalyDetectorDirection.DOWN,
new SuppressCondition(1, 1))
.setLowerBound(5.0);

SmartDetectionCondition smartDetectionCondition = new SmartDetectionCondition(
10.0,
AnomalyDetectorDirection.UP,
new SuppressCondition(1, 2));

final AnomalyDetectionConfiguration anomalyDetectionConfiguration =
metricsAdvisorAdminClient.createMetricAnomalyDetectionConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ Mono<Response<DataFeed>> createDataFeedWithResponse(DataFeed dataFeed, Context c
.setGranularityName(Granularity.fromString(dataFeedGranularity.getGranularityType() == null
? null : dataFeedGranularity.getGranularityType().toString()))
.setGranularityAmount(dataFeedGranularity.getCustomGranularityValue())
.setDimension(dataFeedSchema.getDimensions())
.setMetrics(dataFeedSchema.getMetrics())
.setDimension(DataFeedTransforms.toInnerDimensionsListForCreate(dataFeedSchema.getDimensions()))
.setMetrics(DataFeedTransforms.toInnerMetricsListForCreate(dataFeedSchema.getMetrics()))
.setTimestampColumn(dataFeedSchema.getTimestampColumn())
.setDataStartFrom(dataFeedIngestionSettings.getIngestionStartTime())
.setStartOffsetInSeconds(dataFeedIngestionSettings.getIngestionStartOffset() == null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,145 +1,154 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.ai.metricsadvisor.administration.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The ChangeThresholdCondition model. */
/**
* Type that describes change-threshold parameters. In change-threshold mode, metrics advisor watch for
* any data points that changes over a change percentage compared to the previous data points and detect
* such data points as anomalies.
*/
@Fluent
public final class ChangeThresholdCondition {
/*
* change percentage, value range : [0, +∞)
*/
@JsonProperty(value = "changePercentage", required = true)
private double changePercentage;

/*
* shift point, value range : [1, +∞)
*/
@JsonProperty(value = "shiftPoint", required = true)
private int shiftPoint;

/*
* if the withinRange = true, detected data is abnormal when the value
* falls in the range, in this case anomalyDetectorDirection must be Both
* if the withinRange = false, detected data is abnormal when the value
* falls out of the range
*/
@JsonProperty(value = "withinRange", required = true)
private boolean withinRange;

/*
* detection direction
*/
@JsonProperty(value = "anomalyDetectorDirection", required = true)
private Double changePercentage;
private Integer shiftPoint;
private Boolean isWithinRange;
private AnomalyDetectorDirection anomalyDetectorDirection;
private SuppressCondition suppressCondition;

/*
* The suppressCondition property.
/**
* Create an instance of ChangeThresholdCondition describing how to identify anomalies using
* change-threshold mode.
*
* @param changePercentage the percentage of change that will considered as an anomaly,
* the data point will be compared with previously captured data points
* for computing the change.
* @param shiftPoint the number of data points that detector should look back for comparison.
* @param isWithinRage when set to true, data point is an anomaly when the value falls in the range;
* in this case, detectorDirection must be Both. When set false, the data point
* is an anomaly when the value falls out of the range.
* @param detectorDirection must be {@link AnomalyDetectorDirection#BOTH} when {@code isWithinRage} is true.
* When {@code isWithinRage} is false, An {@link AnomalyDetectorDirection#UP} value indicates that
* the data point should be considered as an anomaly, if its changes (compared to previous data points)
* more than the {@code changePercentage}. {@link AnomalyDetectorDirection#DOWN} value means a data point
* should be considered as anomaly, if the change (compared to previous data points) falls below negated
* {@code changePercentage} value.
* @param suppressCondition the condition to aggregate the anomaly detection reporting,
* suppressing the reporting of individual anomalies helps to avoid noises, especially if the metrics
* have fine granularity.
*/
@JsonProperty(value = "suppressCondition", required = true)
private SuppressCondition suppressCondition;
public ChangeThresholdCondition(double changePercentage,
int shiftPoint,
boolean isWithinRage,
AnomalyDetectorDirection detectorDirection,
SuppressCondition suppressCondition) {
this.changePercentage = changePercentage;
this.shiftPoint = shiftPoint;
this.isWithinRange = isWithinRage;
this.anomalyDetectorDirection = detectorDirection;
this.suppressCondition = suppressCondition;
}

/**
* Get the changePercentage property: change percentage, value range : [0, +∞).
* Gets the percentage of change that will consider a data point as an anomaly.
*
* @return the changePercentage value.
* @return the change percentage value.
*/
public double getChangePercentage() {
return this.changePercentage;
public Double getChangePercentage() {
return changePercentage;
}

/**
* Set the changePercentage property: change percentage, value range : [0, +∞).
* Gets the number of data points that detector should look back for comparison.
*
* @param changePercentage the changePercentage value to set.
* @return the ChangeThresholdCondition object itself.
* @return the shift point value.
*/
public ChangeThresholdCondition setChangePercentage(double changePercentage) {
this.changePercentage = changePercentage;
return this;
public Integer getShiftPoint() {
return shiftPoint;
}

/**
* Get the shiftPoint property: shift point, value range : [1, +∞).
* Gets the flag indicating whether the data point falls within or out of the range is considered as anomaly.
*
* @return the shiftPoint value.
* @return the withinRange value.
*/
public int getShiftPoint() {
return this.shiftPoint;
public Boolean isWithinRange() {
return isWithinRange;
}

/**
* Set the shiftPoint property: shift point, value range : [1, +∞).
* Gets the direction that detector should use when comparing the data point change with change threshold.
*
* @param shiftPoint the shiftPoint value to set.
* @return the ChangeThresholdCondition object itself.
* @return the detector direction.
*/
public ChangeThresholdCondition setShiftPoint(int shiftPoint) {
this.shiftPoint = shiftPoint;
return this;
public AnomalyDetectorDirection getAnomalyDetectorDirection() {
return anomalyDetectorDirection;
}

/**
* Get the withinRange property: if the withinRange = true, detected data is abnormal when the value falls in the
* range, in this case anomalyDetectorDirection must be Both if the withinRange = false, detected data is abnormal
* when the value falls out of the range.
* Gets the suppress condition.
*
* @return the withinRange value.
* @return the suppress condition value.
*/
public boolean isWithinRange() {
return this.withinRange;
public SuppressCondition getSuppressCondition() {
return suppressCondition;
}

/**
* Set the withinRange property: if the withinRange = true, detected data is abnormal when the value falls in the
* range, in this case anomalyDetectorDirection must be Both if the withinRange = false, detected data is abnormal
* when the value falls out of the range.
* Sets the percentage of change that will consider a data point as an anomaly.
*
* @param changePercentage the change percentage value.
*
* @param withinRange the withinRange value to set.
* @return the ChangeThresholdCondition object itself.
*/
public ChangeThresholdCondition setWithinRange(boolean withinRange) {
this.withinRange = withinRange;
public ChangeThresholdCondition setChangePercentage(Double changePercentage) {
this.changePercentage = changePercentage;
return this;
}

/**
* Get the anomalyDetectorDirection property: detection direction.
* Sets the number of data points that detector should look back for comparison.
*
* @return the anomalyDetectorDirection value.
* @param shiftPoint the shift point value.
*
* @return the ChangeThresholdCondition object itself.
*/
public AnomalyDetectorDirection getAnomalyDetectorDirection() {
return this.anomalyDetectorDirection;
public ChangeThresholdCondition setShiftPoint(Integer shiftPoint) {
this.shiftPoint = shiftPoint;
return this;
}

/**
* Set the anomalyDetectorDirection property: detection direction.
* Sets the flag indicating whether the data point falls within or out of the range is considered as anomaly.
*
* @param withinRange the withinRange value.
*
* @param anomalyDetectorDirection the anomalyDetectorDirection value to set.
* @return the ChangeThresholdCondition object itself.
*/
public ChangeThresholdCondition setAnomalyDetectorDirection(AnomalyDetectorDirection anomalyDetectorDirection) {
this.anomalyDetectorDirection = anomalyDetectorDirection;
public ChangeThresholdCondition setWithinRage(Boolean withinRange) {
this.isWithinRange = withinRange;
return this;
}

/**
* Get the suppressCondition property: The suppressCondition property.
* Sets the direction that detector should use when comparing the data point change with change threshold.
*
* @param detectorDirection the detector direction
*
* @return the suppressCondition value.
* @return the ChangeThresholdCondition object itself.
*/
public SuppressCondition getSuppressCondition() {
return this.suppressCondition;
public ChangeThresholdCondition setAnomalyDetectorDirection(AnomalyDetectorDirection detectorDirection) {
this.anomalyDetectorDirection = detectorDirection;
return this;
}

/**
* Set the suppressCondition property: The suppressCondition property.
* Sets the suppress condition.
*
* @param suppressCondition the suppress condition
*
* @param suppressCondition the suppressCondition value to set.
* @return the ChangeThresholdCondition object itself.
*/
public ChangeThresholdCondition setSuppressCondition(SuppressCondition suppressCondition) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,53 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.ai.metricsadvisor.administration.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The DataFeedDimension model. */
/**
* Type describing a dimension of a DataFeed.
*/
@Fluent
public final class DataFeedDimension {
/*
* dimension name
*/
@JsonProperty(value = "dimensionName", required = true)
private String name;

/*
* dimension display name
*/
@JsonProperty(value = "dimensionDisplayName")
private final String name;
private String displayName;

/**
* Get the dimensionName property: dimension name.
* Creates a DataFeedDimension.
*
* @return the dimensionName value.
* @param name the dimension name.
*/
public String getName() {
return this.name;
public DataFeedDimension(String name) {
this.name = name;
}

/**
* Set the dimensionName property: dimension name.
* Gets the dimension name.
*
* @param dimensionName the dimensionName value to set.
* @return the DataFeedDimension object itself.
* @return the dimension name
*/
public DataFeedDimension setName(String dimensionName) {
this.name = dimensionName;
return this;
public String getName() {
return this.name;
}

/**
* Get the dimensionDisplayName property: dimension display name.
* Gets the dimension display name.
*
* @return the dimensionDisplayName value.
* @return the dimension display name
*/
public String getDisplayName() {
return this.displayName;
}

/**
* Set the dimensionDisplayName property: dimension display name.
* Sets the dimension display name.
*
* @param dimensionDisplayName the dimensionDisplayName value to set.
* @param displayName the dimension display name
* @return the DataFeedDimension object itself.
*/
public DataFeedDimension setDisplayName(String dimensionDisplayName) {
this.displayName = dimensionDisplayName;
public DataFeedDimension setDisplayName(String displayName) {
this.displayName = displayName;
return this;
}
}
Loading