TimeSeriesCatalog.DetectIidSpike 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
DetectIidSpike(TransformsCatalog, String, String, Double, Int32, AnomalySide) |
建立 IidSpikeEstimator ,其會根據自適性核心密度估計和 martingale 分數,預測 獨立分佈 (i.d.) 時間序列的尖峰。 |
DetectIidSpike(TransformsCatalog, String, String, Int32, Int32, AnomalySide) |
已淘汰.
建立 IidSpikeEstimator ,其會根據自適性核心密度估計和 martingale 分數,預測 獨立分佈 (i.d.) 時間序列的尖峰。 |
DetectIidSpike(TransformsCatalog, String, String, Double, Int32, AnomalySide)
建立 IidSpikeEstimator ,其會根據自適性核心密度估計和 martingale 分數,預測 獨立分佈 (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 值。
- 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.
建立 IidSpikeEstimator ,其會根據自適性核心密度估計和 martingale 分數,預測 獨立分佈 (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 值。
- 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; }
}
}
}