Share via


AnomalyDetectorClient.TrainMultivariateModelAsync Método

Definición

Sobrecargas

TrainMultivariateModelAsync(ModelInfo, CancellationToken)

Entrenar un modelo de detección de anomalías multivariante.

TrainMultivariateModelAsync(RequestContent, RequestContext)

[Método Protocol] Entrenamiento de un modelo de detección de anomalías multivariante

TrainMultivariateModelAsync(ModelInfo, CancellationToken)

Source:
AnomalyDetectorClient.cs

Entrenar un modelo de detección de anomalías multivariante.

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

Parámetros

modelInfo
ModelInfo

Información del modelo.

cancellationToken
CancellationToken

Token de cancelación que se va a usar.

Devoluciones

Excepciones

modelInfo es null.

Ejemplos

En este ejemplo se muestra cómo llamar a TrainMultivariateModelAsync con los parámetros necesarios.

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

var modelInfo = new ModelInfo("<dataSource>", DateTimeOffset.UtcNow, DateTimeOffset.UtcNow)
{
    DataSchema = DataSchema.OneTable,
    DisplayName = "<DisplayName>",
    SlidingWindow = 1234,
    AlignPolicy = new AlignPolicy()
{
        AlignMode = AlignMode.Inner,
        FillNAMethod = FillNAMethod.Previous,
        PaddingValue = 3.14f,
    },
};
var result = await client.TrainMultivariateModelAsync(modelInfo);

Comentarios

Crea y entrena un modelo de detección de anomalías de multivariante. La solicitud debe incluir un parámetro de origen para indicar un URI de Azure Blob Storage accesible para el servicio. Hay dos tipos de entrada de datos. El URI de Blob Storage puede apuntar a una carpeta Azure Blob Storage que contiene varios archivos CSV, donde cada archivo CSV tiene dos columnas, marca de tiempo y variable. O bien, el URI de Blob Storage puede apuntar a un único blob que contenga un archivo CSV que tenga todas las variables y una columna de marca de tiempo.

Se aplica a

TrainMultivariateModelAsync(RequestContent, RequestContext)

Source:
AnomalyDetectorClient.cs

[Método Protocol] Entrenamiento de un modelo de detección de anomalías multivariante

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

Parámetros

content
RequestContent

Contenido que se va a enviar como el cuerpo de la solicitud.

context
RequestContext

Contexto de solicitud, que puede invalidar los comportamientos predeterminados de la canalización de cliente por llamada.

Devoluciones

Respuesta devuelta desde el servicio.

Excepciones

content es null.

El servicio devolvió un código de estado no correcto.

Ejemplos

En este ejemplo se muestra cómo llamar a TrainMultivariateModelAsync con el contenido de la solicitud necesario y cómo analizar el resultado.

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>",
    startTime = "2022-05-10T14:57:31.2311892-04:00",
    endTime = "2022-05-10T14:57:31.2311892-04:00",
};

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

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("modelId").ToString());
Console.WriteLine(result.GetProperty("createdTime").ToString());
Console.WriteLine(result.GetProperty("lastUpdatedTime").ToString());

En este ejemplo se muestra cómo llamar a TrainMultivariateModelAsync con todo el contenido de la solicitud y cómo analizar el resultado.

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>",
    dataSchema = "OneTable",
    startTime = "2022-05-10T14:57:31.2311892-04:00",
    endTime = "2022-05-10T14:57:31.2311892-04:00",
    displayName = "<displayName>",
    slidingWindow = 1234,
    alignPolicy = new {
        alignMode = "Inner",
        fillNAMethod = "Previous",
        paddingValue = 123.45f,
    },
};

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

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("modelId").ToString());
Console.WriteLine(result.GetProperty("createdTime").ToString());
Console.WriteLine(result.GetProperty("lastUpdatedTime").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("dataSource").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("dataSchema").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("startTime").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("endTime").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("displayName").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("slidingWindow").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("alignPolicy").GetProperty("alignMode").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("alignPolicy").GetProperty("fillNAMethod").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("alignPolicy").GetProperty("paddingValue").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("status").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("errors")[0].GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("errors")[0].GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("diagnosticsInfo").GetProperty("modelState").GetProperty("epochIds")[0].ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("diagnosticsInfo").GetProperty("modelState").GetProperty("trainLosses")[0].ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("diagnosticsInfo").GetProperty("modelState").GetProperty("validationLosses")[0].ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("diagnosticsInfo").GetProperty("modelState").GetProperty("latenciesInSeconds")[0].ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("diagnosticsInfo").GetProperty("variableStates")[0].GetProperty("variable").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("diagnosticsInfo").GetProperty("variableStates")[0].GetProperty("filledNARatio").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("diagnosticsInfo").GetProperty("variableStates")[0].GetProperty("effectiveCount").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("diagnosticsInfo").GetProperty("variableStates")[0].GetProperty("firstTimestamp").ToString());
Console.WriteLine(result.GetProperty("modelInfo").GetProperty("diagnosticsInfo").GetProperty("variableStates")[0].GetProperty("lastTimestamp").ToString());

Comentarios

Crea y entrena un modelo de detección de anomalías de multivariante. La solicitud debe incluir un parámetro de origen para indicar un URI de Azure Blob Storage accesible externamente. Hay dos tipos de entrada de datos: un URI apuntado a una carpeta de Azure Blob Storage que contiene varios archivos CSV y cada archivo CSV contiene dos columnas, marca de tiempo y variable. Otro tipo de entrada es un URI al que apunta un archivo CSV en Azure Blob Storage, que contiene todas las variables y una columna de marca de tiempo.

A continuación se muestra el esquema JSON para las cargas de solicitud y respuesta.

Cuerpo de la solicitud:

Esquema para ModelInfo:

{
  dataSource: string, # Required.
  dataSchema: "OneTable" | "MultiTable", # Optional.
  startTime: string (date & time), # Required.
  endTime: string (date & time), # Required.
  displayName: string, # Optional.
  slidingWindow: number, # Optional.
  alignPolicy: {
    alignMode: "Inner" | "Outer", # Optional.
    fillNAMethod: "Previous" | "Subsequent" | "Linear" | "Zero" | "Fixed", # Optional.
    paddingValue: number, # Optional.
  }, # Optional.
  status: "CREATED" | "RUNNING" | "READY" | "FAILED", # Optional.
  errors: [
    {
      code: string, # Required.
      message: string, # Required.
    }
  ], # Optional.
  diagnosticsInfo: {
    modelState: {
      epochIds: [number], # Optional.
      trainLosses: [number], # Optional.
      validationLosses: [number], # Optional.
      latenciesInSeconds: [number], # Optional.
    }, # Optional.
    variableStates: [VariableState], # Optional.
  }, # Optional.
}

Cuerpo de la respuesta:

Esquema para AnomalyDetectionModel:

{
  modelId: string, # Required.
  createdTime: string (date & time), # Required.
  lastUpdatedTime: string (date & time), # Required.
  modelInfo: {
    dataSource: string, # Required.
    dataSchema: "OneTable" | "MultiTable", # Optional.
    startTime: string (date & time), # Required.
    endTime: string (date & time), # Required.
    displayName: string, # Optional.
    slidingWindow: number, # Optional.
    alignPolicy: {
      alignMode: "Inner" | "Outer", # Optional.
      fillNAMethod: "Previous" | "Subsequent" | "Linear" | "Zero" | "Fixed", # Optional.
      paddingValue: number, # Optional.
    }, # Optional.
    status: "CREATED" | "RUNNING" | "READY" | "FAILED", # Optional.
    errors: [
      {
        code: string, # Required.
        message: string, # Required.
      }
    ], # Optional.
    diagnosticsInfo: {
      modelState: {
        epochIds: [number], # Optional.
        trainLosses: [number], # Optional.
        validationLosses: [number], # Optional.
        latenciesInSeconds: [number], # Optional.
      }, # Optional.
      variableStates: [VariableState], # Optional.
    }, # Optional.
  }, # Optional.
}

Se aplica a