Share via


AnomalyDetectorClient.DetectUnivariateEntireSeriesAsync Method

Definition

Overloads

DetectUnivariateEntireSeriesAsync(RequestContent, RequestContext)

[Protocol Method] Detect anomalies for the entire series in batch.

DetectUnivariateEntireSeriesAsync(UnivariateDetectionOptions, CancellationToken)

Detect anomalies for the entire series in batch.

DetectUnivariateEntireSeriesAsync(RequestContent, RequestContext)

Source:
AnomalyDetectorClient.cs

[Protocol Method] Detect anomalies for the entire series in batch.

public virtual System.Threading.Tasks.Task<Azure.Response> DetectUnivariateEntireSeriesAsync (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member DetectUnivariateEntireSeriesAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.DetectUnivariateEntireSeriesAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function DetectUnivariateEntireSeriesAsync (content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameters

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

content is null.

Service returned a non-success status code.

Examples

This sample shows how to call DetectUnivariateEntireSeriesAsync with required request content, and how to parse the result.

var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new AnomalyDetectorClient(endpoint, credential);

var data = new {
    series = new[] {
        new {
            value = 123.45f,
        }
    },
};

Response response = await client.DetectUnivariateEntireSeriesAsync(RequestContent.Create(data));

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("period").ToString());
Console.WriteLine(result.GetProperty("expectedValues")[0].ToString());
Console.WriteLine(result.GetProperty("upperMargins")[0].ToString());
Console.WriteLine(result.GetProperty("lowerMargins")[0].ToString());
Console.WriteLine(result.GetProperty("isAnomaly")[0].ToString());
Console.WriteLine(result.GetProperty("isNegativeAnomaly")[0].ToString());
Console.WriteLine(result.GetProperty("isPositiveAnomaly")[0].ToString());

This sample shows how to call DetectUnivariateEntireSeriesAsync with all request content, and how to parse the result.

var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new AnomalyDetectorClient(endpoint, credential);

var data = new {
    series = new[] {
        new {
            timestamp = "2022-05-10T14:57:31.2311892-04:00",
            value = 123.45f,
        }
    },
    granularity = "yearly",
    customInterval = 1234,
    period = 1234,
    maxAnomalyRatio = 123.45f,
    sensitivity = 1234,
    imputeMode = "auto",
    imputeFixedValue = 123.45f,
};

Response response = await client.DetectUnivariateEntireSeriesAsync(RequestContent.Create(data), new RequestContext());

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("period").ToString());
Console.WriteLine(result.GetProperty("expectedValues")[0].ToString());
Console.WriteLine(result.GetProperty("upperMargins")[0].ToString());
Console.WriteLine(result.GetProperty("lowerMargins")[0].ToString());
Console.WriteLine(result.GetProperty("isAnomaly")[0].ToString());
Console.WriteLine(result.GetProperty("isNegativeAnomaly")[0].ToString());
Console.WriteLine(result.GetProperty("isPositiveAnomaly")[0].ToString());
Console.WriteLine(result.GetProperty("severity")[0].ToString());

Remarks

This operation generates a model with an entire series, each point is detected with the same model. With this method, points before and after a certain point are used to determine whether it is an anomaly. The entire detection can give user an overall status of the time series.

Below is the JSON schema for the request and response payloads.

Request Body:

Schema for UnivariateDetectionOptions:

{
  series: [
    {
      timestamp: string (date & time), # Optional.
      value: number, # Required.
    }
  ], # Required.
  granularity: "yearly" | "monthly" | "weekly" | "daily" | "hourly" | "minutely" | "secondly" | "microsecond" | "none", # Optional.
  customInterval: number, # Optional.
  period: number, # Optional.
  maxAnomalyRatio: number, # Optional.
  sensitivity: number, # Optional.
  imputeMode: "auto" | "previous" | "linear" | "fixed" | "zero" | "notFill", # Optional.
  imputeFixedValue: number, # Optional.
}

Response Body:

Schema for UnivariateEntireDetectionResult:

{
  period: number, # Required.
  expectedValues: [number], # Required.
  upperMargins: [number], # Required.
  lowerMargins: [number], # Required.
  isAnomaly: [boolean], # Required.
  isNegativeAnomaly: [boolean], # Required.
  isPositiveAnomaly: [boolean], # Required.
  severity: [number], # Optional.
}

Applies to

DetectUnivariateEntireSeriesAsync(UnivariateDetectionOptions, CancellationToken)

Source:
AnomalyDetectorClient.cs

Detect anomalies for the entire series in batch.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.AnomalyDetector.UnivariateEntireDetectionResult>> DetectUnivariateEntireSeriesAsync (Azure.AI.AnomalyDetector.UnivariateDetectionOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member DetectUnivariateEntireSeriesAsync : Azure.AI.AnomalyDetector.UnivariateDetectionOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.AnomalyDetector.UnivariateEntireDetectionResult>>
override this.DetectUnivariateEntireSeriesAsync : Azure.AI.AnomalyDetector.UnivariateDetectionOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.AnomalyDetector.UnivariateEntireDetectionResult>>
Public Overridable Function DetectUnivariateEntireSeriesAsync (options As UnivariateDetectionOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of UnivariateEntireDetectionResult))

Parameters

options
UnivariateDetectionOptions

Method of univariate anomaly detection.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

options is null.

Examples

This sample shows how to call DetectUnivariateEntireSeriesAsync with required parameters.

var credential = new AzureKeyCredential("<key>");
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new AnomalyDetectorClient(endpoint, credential);

var options = new UnivariateDetectionOptions(new TimeSeriesPoint[] 
{
    new TimeSeriesPoint(3.14f)
{
        Timestamp = DateTimeOffset.UtcNow,
    }
})
{
    Granularity = TimeGranularity.Yearly,
    CustomInterval = 1234,
    Period = 1234,
    MaxAnomalyRatio = 3.14f,
    Sensitivity = 1234,
    ImputeMode = ImputeMode.Auto,
    ImputeFixedValue = 3.14f,
};
var result = await client.DetectUnivariateEntireSeriesAsync(options);

Remarks

This operation generates a model with an entire series. Each point is detected with the same model. With this method, points before and after a certain point are used to determine whether it's an anomaly. The entire detection can give the user an overall status of the time series.

Applies to