Condividi tramite


AnomalyDetectorClient.DetectMultivariateBatchAnomalyAsync Method

Definition

Overloads

DetectMultivariateBatchAnomalyAsync(String, MultivariateBatchDetectionOptions, CancellationToken)

Detect Multivariate Anomaly.

DetectMultivariateBatchAnomalyAsync(String, RequestContent, RequestContext)

[Protocol Method] Detect Multivariate Anomaly

DetectMultivariateBatchAnomalyAsync(String, MultivariateBatchDetectionOptions, CancellationToken)

Source:
AnomalyDetectorClient.cs

Detect Multivariate Anomaly.

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

Parameters

modelId
String

Model identifier.

options
MultivariateBatchDetectionOptions

Request of multivariate anomaly detection.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

modelId or options is null.

modelId is an empty string, and was expected to be non-empty.

Examples

This sample shows how to call DetectMultivariateBatchAnomalyAsync 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 MultivariateBatchDetectionOptions("<dataSource>", 1234, DateTimeOffset.UtcNow, DateTimeOffset.UtcNow);
var result = await client.DetectMultivariateBatchAnomalyAsync("<modelId>", options);

Remarks

Submit a multivariate anomaly detection task with the modelId value of a trained model and inference data. The input schema should be the same with the training request. The request will finish asynchronously and return a resultId value to query the detection result. The request should be a source link to indicate an externally accessible Azure Storage URI that either points to an Azure Blob Storage folder or points to a CSV file in Azure Blob Storage.

Applies to

DetectMultivariateBatchAnomalyAsync(String, RequestContent, RequestContext)

Source:
AnomalyDetectorClient.cs

[Protocol Method] Detect Multivariate Anomaly

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

Parameters

modelId
String

Model identifier.

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

modelId or content is null.

modelId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call DetectMultivariateBatchAnomalyAsync with required parameters and request content and 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 {
    dataSource = "<dataSource>",
    topContributorCount = 1234,
    startTime = "2022-05-10T14:57:31.2311892-04:00",
    endTime = "2022-05-10T14:57:31.2311892-04:00",
};

Response response = await client.DetectMultivariateBatchAnomalyAsync("<modelId>", RequestContent.Create(data), new RequestContext());

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("resultId").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("errors")[0].GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("errors")[0].GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("variableStates")[0].GetProperty("variable").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("variableStates")[0].GetProperty("filledNARatio").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("variableStates")[0].GetProperty("effectiveCount").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("variableStates")[0].GetProperty("firstTimestamp").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("variableStates")[0].GetProperty("lastTimestamp").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("dataSource").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("topContributorCount").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("startTime").ToString());
Console.WriteLine(result.GetProperty("summary").GetProperty("setupInfo").GetProperty("endTime").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("timestamp").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("value").GetProperty("isAnomaly").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("value").GetProperty("severity").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("value").GetProperty("score").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("value").GetProperty("interpretation")[0].GetProperty("variable").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("value").GetProperty("interpretation")[0].GetProperty("contributionScore").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("value").GetProperty("interpretation")[0].GetProperty("correlationChanges").GetProperty("changedVariables")[0].ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("errors")[0].GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("results")[0].GetProperty("errors")[0].GetProperty("message").ToString());

Remarks

Submit multivariate anomaly detection task with the modelId of trained model and inference data, the input schema should be the same with the training request. The request will complete asynchronously and return a resultId to query the detection result.The request should be a source link to indicate an externally accessible Azure storage Uri, either pointed to an Azure blob storage folder, or pointed to a CSV file in Azure blob storage.

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

Request Body:

Schema for MultivariateBatchDetectionOptions:

{
  dataSource: string, # Required.
  topContributorCount: number, # Required.
  startTime: string (date & time), # Required.
  endTime: string (date & time), # Required.
}

Response Body:

Schema for MultivariateDetectionResult:

{
  resultId: string, # Required.
  summary: {
    status: "CREATED" | "RUNNING" | "READY" | "FAILED", # Required.
    errors: [ErrorResponse], # Optional.
    variableStates: [VariableState], # Optional.
    setupInfo: {
      dataSource: string, # Required.
      topContributorCount: number, # Required.
      startTime: string (date & time), # Required.
      endTime: string (date & time), # Required.
    }, # Required.
  }, # Required.
  results: [
    {
      timestamp: string (date & time), # Required.
      value: {
        isAnomaly: boolean, # Required.
        severity: number, # Required.
        score: number, # Required.
        interpretation: [AnomalyInterpretation], # Optional.
      }, # Optional.
      errors: [ErrorResponse], # Optional.
    }
  ], # Required.
}

Applies to