Share via


AnomalyDetectorClient.DetectUnivariateLastPointAsync Method

Definition

Overloads

DetectUnivariateLastPointAsync(UnivariateDetectionOptions, CancellationToken)

Detect anomaly status of the latest point in time series.

DetectUnivariateLastPointAsync(RequestContent, RequestContext)

[Protocol Method] Detect anomaly status of the latest point in time series.

DetectUnivariateLastPointAsync(UnivariateDetectionOptions, CancellationToken)

Source:
AnomalyDetectorClient.cs

Detect anomaly status of the latest point in time series.

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

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 DetectUnivariateLastPointAsync 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.DetectUnivariateLastPointAsync(options);

Remarks

This operation generates a model by using the points that you sent in to the API and based on all data to determine whether the last point is anomalous.

Applies to

DetectUnivariateLastPointAsync(RequestContent, RequestContext)

Source:
AnomalyDetectorClient.cs

[Protocol Method] Detect anomaly status of the latest point in time series.

public virtual System.Threading.Tasks.Task<Azure.Response> DetectUnivariateLastPointAsync (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member DetectUnivariateLastPointAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.DetectUnivariateLastPointAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function DetectUnivariateLastPointAsync (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 DetectUnivariateLastPointAsync 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.DetectUnivariateLastPointAsync(RequestContent.Create(data));

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("period").ToString());
Console.WriteLine(result.GetProperty("suggestedWindow").ToString());
Console.WriteLine(result.GetProperty("expectedValue").ToString());
Console.WriteLine(result.GetProperty("upperMargin").ToString());
Console.WriteLine(result.GetProperty("lowerMargin").ToString());
Console.WriteLine(result.GetProperty("isAnomaly").ToString());
Console.WriteLine(result.GetProperty("isNegativeAnomaly").ToString());
Console.WriteLine(result.GetProperty("isPositiveAnomaly").ToString());

This sample shows how to call DetectUnivariateLastPointAsync 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.DetectUnivariateLastPointAsync(RequestContent.Create(data), new RequestContext());

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("period").ToString());
Console.WriteLine(result.GetProperty("suggestedWindow").ToString());
Console.WriteLine(result.GetProperty("expectedValue").ToString());
Console.WriteLine(result.GetProperty("upperMargin").ToString());
Console.WriteLine(result.GetProperty("lowerMargin").ToString());
Console.WriteLine(result.GetProperty("isAnomaly").ToString());
Console.WriteLine(result.GetProperty("isNegativeAnomaly").ToString());
Console.WriteLine(result.GetProperty("isPositiveAnomaly").ToString());
Console.WriteLine(result.GetProperty("severity").ToString());

Remarks

This operation generates a model using the points that you sent into the API, and based on all data to determine whether the last point is anomalous.

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

{
  period: number, # Required.
  suggestedWindow: number, # Required.
  expectedValue: number, # Required.
  upperMargin: number, # Required.
  lowerMargin: number, # Required.
  isAnomaly: boolean, # Required.
  isNegativeAnomaly: boolean, # Required.
  isPositiveAnomaly: boolean, # Required.
  severity: number, # Optional.
}

Applies to