TimeSeriesCatalog.DetectIidSpike 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
DetectIidSpike(TransformsCatalog, String, String, Double, Int32, AnomalySide) |
Create IidSpikeEstimator,它根据自适应内核密度估计和马丁加尔分数预测 独立分布 (i.i.d.) 时序中的峰值。 |
DetectIidSpike(TransformsCatalog, String, String, Int32, Int32, AnomalySide) |
已过时.
Create IidSpikeEstimator,它根据自适应内核密度估计和马丁加尔分数预测 独立分布 (i.i.d.) 时序中的峰值。 |
DetectIidSpike(TransformsCatalog, String, String, Double, Int32, AnomalySide)
Create IidSpikeEstimator,它根据自适应内核密度估计和马丁加尔分数预测 独立分布 (i.i.d.) 时序中的峰值。
public static Microsoft.ML.Transforms.TimeSeries.IidSpikeEstimator DetectIidSpike (this Microsoft.ML.TransformsCatalog catalog, string outputColumnName, string inputColumnName, double confidence, int pvalueHistoryLength, Microsoft.ML.Transforms.TimeSeries.AnomalySide side = Microsoft.ML.Transforms.TimeSeries.AnomalySide.TwoSided);
static member DetectIidSpike : Microsoft.ML.TransformsCatalog * string * string * double * int * Microsoft.ML.Transforms.TimeSeries.AnomalySide -> Microsoft.ML.Transforms.TimeSeries.IidSpikeEstimator
<Extension()>
Public Function DetectIidSpike (catalog As TransformsCatalog, outputColumnName As String, inputColumnName As String, confidence As Double, pvalueHistoryLength As Integer, Optional side As AnomalySide = Microsoft.ML.Transforms.TimeSeries.AnomalySide.TwoSided) As IidSpikeEstimator
参数
- catalog
- TransformsCatalog
转换的目录。
- outputColumnName
- String
由转换 inputColumnName
生成的列的名称。
列数据是一个向量 Double。 矢量包含 3 个元素:警报 (非零值表示峰值) 、原始分数和 p 值。
- inputColumnName
- String
要转换的列的名称。 列数据必须是 Single。
If set to null
, the value of the outputColumnName
will be used as source.
- confidence
- Double
[0, 100] 范围内的峰值检测置信度。
- pvalueHistoryLength
- Int32
用于计算 p 值的滑动窗口的大小。
- side
- AnomalySide
确定是检测正异常还是负异常还是同时检测两者的参数。
返回
示例
using System;
using System.Collections.Generic;
using Microsoft.ML;
using Microsoft.ML.Data;
namespace Samples.Dynamic
{
public static class DetectIidSpikeBatchPrediction
{
// This example creates a time series (list of Data with the i-th element
// corresponding to the i-th time slot). The estimator is applied then to
// identify spiking points in the series.
public static void Example()
{
// Create a new ML context, for ML.NET operations. It can be used for
// exception tracking and logging, as well as the source of randomness.
var ml = new MLContext();
// Generate sample series data with a spike
const int Size = 10;
var data = new List<TimeSeriesData>(Size + 1)
{
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
// This is a spike.
new TimeSeriesData(10),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
};
// Convert data to IDataView.
var dataView = ml.Data.LoadFromEnumerable(data);
// Setup the estimator arguments
string outputColumnName = nameof(IidSpikePrediction.Prediction);
string inputColumnName = nameof(TimeSeriesData.Value);
// The transformed data.
var transformedData = ml.Transforms.DetectIidSpike(outputColumnName,
inputColumnName, 95.0d, Size / 4).Fit(dataView).Transform(dataView);
// Getting the data of the newly created column as an IEnumerable of
// IidSpikePrediction.
var predictionColumn = ml.Data.CreateEnumerable<IidSpikePrediction>(
transformedData, reuseRowObject: false);
Console.WriteLine($"{outputColumnName} column obtained " +
$"post-transformation.");
Console.WriteLine("Data\tAlert\tScore\tP-Value");
int k = 0;
foreach (var prediction in predictionColumn)
PrintPrediction(data[k++].Value, prediction);
// Prediction column obtained post-transformation.
// Data Alert Score P-Value
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 10 1 10.00 0.00 <-- alert is on, predicted spike
// 5 0 5.00 0.26
// 5 0 5.00 0.26
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 5 0 5.00 0.50
}
private static void PrintPrediction(float value, IidSpikePrediction
prediction) =>
Console.WriteLine("{0}\t{1}\t{2:0.00}\t{3:0.00}", value,
prediction.Prediction[0], prediction.Prediction[1],
prediction.Prediction[2]);
class TimeSeriesData
{
public float Value;
public TimeSeriesData(float value)
{
Value = value;
}
}
class IidSpikePrediction
{
[VectorType(3)]
public double[] Prediction { get; set; }
}
}
}
适用于
DetectIidSpike(TransformsCatalog, String, String, Int32, Int32, AnomalySide)
注意
This API method is deprecated, please use the overload with confidence parameter of type double.
Create IidSpikeEstimator,它根据自适应内核密度估计和马丁加尔分数预测 独立分布 (i.i.d.) 时序中的峰值。
[System.Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")]
public static Microsoft.ML.Transforms.TimeSeries.IidSpikeEstimator DetectIidSpike (this Microsoft.ML.TransformsCatalog catalog, string outputColumnName, string inputColumnName, int confidence, int pvalueHistoryLength, Microsoft.ML.Transforms.TimeSeries.AnomalySide side = Microsoft.ML.Transforms.TimeSeries.AnomalySide.TwoSided);
public static Microsoft.ML.Transforms.TimeSeries.IidSpikeEstimator DetectIidSpike (this Microsoft.ML.TransformsCatalog catalog, string outputColumnName, string inputColumnName, int confidence, int pvalueHistoryLength, Microsoft.ML.Transforms.TimeSeries.AnomalySide side = Microsoft.ML.Transforms.TimeSeries.AnomalySide.TwoSided);
[<System.Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")>]
static member DetectIidSpike : Microsoft.ML.TransformsCatalog * string * string * int * int * Microsoft.ML.Transforms.TimeSeries.AnomalySide -> Microsoft.ML.Transforms.TimeSeries.IidSpikeEstimator
static member DetectIidSpike : Microsoft.ML.TransformsCatalog * string * string * int * int * Microsoft.ML.Transforms.TimeSeries.AnomalySide -> Microsoft.ML.Transforms.TimeSeries.IidSpikeEstimator
<Extension()>
Public Function DetectIidSpike (catalog As TransformsCatalog, outputColumnName As String, inputColumnName As String, confidence As Integer, pvalueHistoryLength As Integer, Optional side As AnomalySide = Microsoft.ML.Transforms.TimeSeries.AnomalySide.TwoSided) As IidSpikeEstimator
参数
- catalog
- TransformsCatalog
转换的目录。
- outputColumnName
- String
由转换 inputColumnName
生成的列的名称。
列数据是一个向量 Double。 矢量包含 3 个元素:警报 (非零值表示峰值) 、原始分数和 p 值。
- inputColumnName
- String
要转换的列的名称。 列数据必须是 Single。
If set to null
, the value of the outputColumnName
will be used as source.
- confidence
- Int32
[0, 100] 范围内的峰值检测置信度。
- pvalueHistoryLength
- Int32
用于计算 p 值的滑动窗口的大小。
- side
- AnomalySide
确定是检测正异常还是负异常还是同时检测两者的参数。
返回
- 属性
示例
using System;
using System.Collections.Generic;
using Microsoft.ML;
using Microsoft.ML.Data;
namespace Samples.Dynamic
{
public static class DetectIidSpikeBatchPrediction
{
// This example creates a time series (list of Data with the i-th element
// corresponding to the i-th time slot). The estimator is applied then to
// identify spiking points in the series.
public static void Example()
{
// Create a new ML context, for ML.NET operations. It can be used for
// exception tracking and logging, as well as the source of randomness.
var ml = new MLContext();
// Generate sample series data with a spike
const int Size = 10;
var data = new List<TimeSeriesData>(Size + 1)
{
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
// This is a spike.
new TimeSeriesData(10),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
new TimeSeriesData(5),
};
// Convert data to IDataView.
var dataView = ml.Data.LoadFromEnumerable(data);
// Setup the estimator arguments
string outputColumnName = nameof(IidSpikePrediction.Prediction);
string inputColumnName = nameof(TimeSeriesData.Value);
// The transformed data.
var transformedData = ml.Transforms.DetectIidSpike(outputColumnName,
inputColumnName, 95.0d, Size / 4).Fit(dataView).Transform(dataView);
// Getting the data of the newly created column as an IEnumerable of
// IidSpikePrediction.
var predictionColumn = ml.Data.CreateEnumerable<IidSpikePrediction>(
transformedData, reuseRowObject: false);
Console.WriteLine($"{outputColumnName} column obtained " +
$"post-transformation.");
Console.WriteLine("Data\tAlert\tScore\tP-Value");
int k = 0;
foreach (var prediction in predictionColumn)
PrintPrediction(data[k++].Value, prediction);
// Prediction column obtained post-transformation.
// Data Alert Score P-Value
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 10 1 10.00 0.00 <-- alert is on, predicted spike
// 5 0 5.00 0.26
// 5 0 5.00 0.26
// 5 0 5.00 0.50
// 5 0 5.00 0.50
// 5 0 5.00 0.50
}
private static void PrintPrediction(float value, IidSpikePrediction
prediction) =>
Console.WriteLine("{0}\t{1}\t{2:0.00}\t{3:0.00}", value,
prediction.Prediction[0], prediction.Prediction[1],
prediction.Prediction[2]);
class TimeSeriesData
{
public float Value;
public TimeSeriesData(float value)
{
Value = value;
}
}
class IidSpikePrediction
{
[VectorType(3)]
public double[] Prediction { get; set; }
}
}
}