Share via


AnomalyDetectorClient.DetectMultivariateLastAnomaly Method

Definition

Overloads

DetectMultivariateLastAnomaly(String, RequestContent, RequestContext)

[Protocol Method] Detect anomalies in the last point of the request body

DetectMultivariateLastAnomaly(String, MultivariateLastDetectionOptions, CancellationToken)

Detect anomalies in the last point of the request body.

DetectMultivariateLastAnomaly(String, RequestContent, RequestContext)

Source:
AnomalyDetectorClient.cs

[Protocol Method] Detect anomalies in the last point of the request body

public virtual Azure.Response DetectMultivariateLastAnomaly (string modelId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member DetectMultivariateLastAnomaly : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.DetectMultivariateLastAnomaly : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function DetectMultivariateLastAnomaly (modelId As String, content As RequestContent, Optional context As RequestContext = Nothing) As 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 DetectMultivariateLastAnomaly with required parameters and 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 {
    variables = new[] {
        new {
            variable = "<variable>",
            timestamps = new[] {
                "<String>"
            },
            values = new[] {
                123.45f
            },
        }
    },
};

Response response = client.DetectMultivariateLastAnomaly("<modelId>", RequestContent.Create(data));

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());

This sample shows how to call DetectMultivariateLastAnomaly with all parameters and 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 {
    variables = new[] {
        new {
            variable = "<variable>",
            timestamps = new[] {
                "<String>"
            },
            values = new[] {
                123.45f
            },
        }
    },
    topContributorCount = 1234,
};

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

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("variableStates")[0].GetProperty("variable").ToString());
Console.WriteLine(result.GetProperty("variableStates")[0].GetProperty("filledNARatio").ToString());
Console.WriteLine(result.GetProperty("variableStates")[0].GetProperty("effectiveCount").ToString());
Console.WriteLine(result.GetProperty("variableStates")[0].GetProperty("firstTimestamp").ToString());
Console.WriteLine(result.GetProperty("variableStates")[0].GetProperty("lastTimestamp").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, and the inference data should be put into request body in a JSON format. The request will complete synchronously and return the detection immediately in the response body.

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

Request Body:

Schema for MultivariateLastDetectionOptions:

{
  variables: [
    {
      variable: string, # Required.
      timestamps: [string], # Required.
      values: [number], # Required.
    }
  ], # Required.
  topContributorCount: number, # Required.
}

Response Body:

Schema for MultivariateLastDetectionResult:

{
  variableStates: [
    {
      variable: string, # Optional.
      filledNARatio: number, # Optional.
      effectiveCount: number, # Optional.
      firstTimestamp: string (date & time), # Optional.
      lastTimestamp: string (date & time), # Optional.
    }
  ], # Optional.
  results: [AnomalyState], # Optional.
}

Applies to

DetectMultivariateLastAnomaly(String, MultivariateLastDetectionOptions, CancellationToken)

Source:
AnomalyDetectorClient.cs

Detect anomalies in the last point of the request body.

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

Parameters

modelId
String

Model identifier.

options
MultivariateLastDetectionOptions

Request of the last 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 DetectMultivariateLastAnomaly 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 MultivariateLastDetectionOptions(new VariableValues[] 
{
    new VariableValues("<variable>", new string[] 
{
        "<null>"
    }, new float[] 
{
        3.14f
    })
})
{
    TopContributorCount = 1234,
};
var result = client.DetectMultivariateLastAnomaly("<modelId>", options);

Remarks

Submit a multivariate anomaly detection task with the modelId value of a trained model and inference data. The inference data should be put into the request body in JSON format. The request will finish synchronously and return the detection immediately in the response body.

Applies to