操作指南:对时序数据使用异常检测器 APIHow to: Use the Anomaly Detector API on your time series data

异常检测器 API 提供两种异常情况检测方法。The Anomaly Detector API provides two methods of anomaly detection. 可以在整个时序中以批处理方式检测异常,也可以在生成数据时通过检测最新数据点的异常状态来检测异常。You can either detect anomalies as a batch throughout your times series, or as your data is generated by detecting the anomaly status of the latest data point. 检测模型将返回异常结果以及每个数据点的预期值,还会返回异常情况检测的上下边界。The detection model returns anomaly results along with each data point's expected value, and the upper and lower anomaly detection boundaries. 可使用这些值来直观显示数据中正常值的范围和异常。you can use these values to visualize the range of normal values, and anomalies in the data.

异常情况检测模式Anomaly detection modes

异常检测器 API 提供两种检测模式:批处理和流式处理。The Anomaly Detector API provides detection modes: batch and streaming.

备注

以下请求 URL 必须与订阅的相应终结点结合。The following request URLs must be combined with the appropriate endpoint for your subscription. 例如: https://<your-custom-subdomain>.api.cognitive.azure.cn/anomalydetector/v1.0/timeseries/entire/detectFor example: https://<your-custom-subdomain>.api.cognitive.azure.cn/anomalydetector/v1.0/timeseries/entire/detect

批量检测Batch detection

若要检测给定的时间范围内一批数据点的异常情况,请将以下请求 URI 用于时序数据:To detect anomalies throughout a batch of data points over a given time range, use the following request URI with your time series data:

/timeseries/entire/detect/timeseries/entire/detect.

通过立刻发送时序数据,API 将使用整个时序生成一个模型,并用它分析每个数据点。By sending your time series data at once, the API will generate a model using the entire series, and analyze each data point with it.

流式处理检测Streaming detection

若要持续检测流数据的异常情况,请将以下请求 URI 用于最新的数据点:To continuously detect anomalies on streaming data, use the following request URI with your latest data point:

/timeseries/last/detect'/timeseries/last/detect'.

通过在生成新数据点的同时发送这些数据点,可以实时监视数据。By sending new data points as you generate them, you can monitor your data in real time. 将使用发送的数据点生成一个模型,并且 API 将确定时序中的最新点是否异常。A model will be generated with the data points you send, and the API will determine if the latest point in the time series is an anomaly.

调整异常情况检测的上下边界Adjusting lower and upper anomaly detection boundaries

默认情况下,使用 expectedValueupperMarginlowerMargin 计算异常情况检测的上下边界。By default, the upper and lower boundaries for anomaly detection are calculated using expectedValue, upperMargin, and lowerMargin. 如果需要不同的边界,建议对 upperMarginlowerMargin 应用 marginScaleIf you require different boundaries, we recommend applying a marginScale to upperMargin or lowerMargin. 边界的计算公式如下:The boundaries would be calculated as follows:

边界Boundary 计算Calculation
upperBoundary expectedValue + (100 - marginScale) * upperMargin
lowerBoundary expectedValue - (100 - marginScale) * lowerMargin

以下示例显示了不同敏感度的异常检测器 API 结果。The following examples show an Anomaly Detector API result at different sensitivities.

敏感度为 99 的示例Example with sensitivity at 99

默认敏感度

敏感度为 95 的示例Example with sensitivity at 95

敏感度 99

敏感度为 85 的示例Example with sensitivity at 85

敏感度 85

后续步骤Next Steps