TimeSeriesCatalog.DetectEntireAnomalyBySrCnn メソッド

定義

オーバーロード

DetectEntireAnomalyBySrCnn(AnomalyDetectionCatalog, IDataView, String, String, SrCnnEntireAnomalyDetectorOptions)

SRCNN アルゴリズムを使用して入力全体の時系列の異常を検出する Create Microsoft.ML.TimeSeries.SrCnnEntireAnomalyDetector

DetectEntireAnomalyBySrCnn(AnomalyDetectionCatalog, IDataView, String, String, Double, Int32, Double, SrCnnDetectMode)

SRCNN アルゴリズムを使用して入力全体の時系列の異常を検出する Create Microsoft.ML.TimeSeries.SrCnnEntireAnomalyDetector

DetectEntireAnomalyBySrCnn(AnomalyDetectionCatalog, IDataView, String, String, SrCnnEntireAnomalyDetectorOptions)

SRCNN アルゴリズムを使用して入力全体の時系列の異常を検出する Create Microsoft.ML.TimeSeries.SrCnnEntireAnomalyDetector

public static Microsoft.ML.IDataView DetectEntireAnomalyBySrCnn (this Microsoft.ML.AnomalyDetectionCatalog catalog, Microsoft.ML.IDataView input, string outputColumnName, string inputColumnName, Microsoft.ML.TimeSeries.SrCnnEntireAnomalyDetectorOptions options);
static member DetectEntireAnomalyBySrCnn : Microsoft.ML.AnomalyDetectionCatalog * Microsoft.ML.IDataView * string * string * Microsoft.ML.TimeSeries.SrCnnEntireAnomalyDetectorOptions -> Microsoft.ML.IDataView
<Extension()>
Public Function DetectEntireAnomalyBySrCnn (catalog As AnomalyDetectionCatalog, input As IDataView, outputColumnName As String, inputColumnName As String, options As SrCnnEntireAnomalyDetectorOptions) As IDataView

パラメーター

catalog
AnomalyDetectionCatalog

AnomalyDetectionCatalog。

input
IDataView

DataView を入力します。

outputColumnName
String

のデータ処理に起因する列の inputColumnName名前。 列データは次のベクトルです Double。 このベクトルの長さはによって異なります options.DetectMode.DetectMode

inputColumnName
String

処理する列の名前。 列データは次の値にする Double必要があります。

options
SrCnnEntireAnomalyDetectorOptions

読み込み操作の設定を定義します。

戻り値

using System;
using System.Collections.Generic;
using Microsoft.ML;
using Microsoft.ML.Data;
using Microsoft.ML.TimeSeries;

namespace Samples.Dynamic
{
    public static class DetectEntireAnomalyBySrCnn
    {
        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 an anomaly
            var data = new List<TimeSeriesData>();
            for (int index = 0; index < 20; index++)
            {
                data.Add(new TimeSeriesData { Value = 5 });
            }
            data.Add(new TimeSeriesData { Value = 10 });
            for (int index = 0; index < 5; index++)
            {
                data.Add(new TimeSeriesData { Value = 5 });
            }

            // Convert data to IDataView.
            var dataView = ml.Data.LoadFromEnumerable(data);

            // Setup the detection arguments
            string outputColumnName = nameof(SrCnnAnomalyDetection.Prediction);
            string inputColumnName = nameof(TimeSeriesData.Value);

            // Do batch anomaly detection
            var outputDataView = ml.AnomalyDetection.DetectEntireAnomalyBySrCnn(dataView, outputColumnName, inputColumnName,
                threshold: 0.35, batchSize: 512, sensitivity: 90.0, detectMode: SrCnnDetectMode.AnomalyAndMargin);

            // Getting the data of the newly created column as an IEnumerable of
            // SrCnnAnomalyDetection.
            var predictionColumn = ml.Data.CreateEnumerable<SrCnnAnomalyDetection>(
                outputDataView, reuseRowObject: false);

            Console.WriteLine("Index\tData\tAnomaly\tAnomalyScore\tMag\tExpectedValue\tBoundaryUnit\tUpperBoundary\tLowerBoundary");

            int k = 0;
            foreach (var prediction in predictionColumn)
            {
                PrintPrediction(k, data[k].Value, prediction);
                k++;
            }
            //Index Data    Anomaly AnomalyScore    Mag ExpectedValue   BoundaryUnit UpperBoundary   LowerBoundary
            //0       5.00    0               0.00    0.21            5.00            5.00            5.01            4.99
            //1       5.00    0               0.00    0.11            5.00            5.00            5.01            4.99
            //2       5.00    0               0.00    0.03            5.00            5.00            5.01            4.99
            //3       5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //4       5.00    0               0.00    0.03            5.00            5.00            5.01            4.99
            //5       5.00    0               0.00    0.06            5.00            5.00            5.01            4.99
            //6       5.00    0               0.00    0.02            5.00            5.00            5.01            4.99
            //7       5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //8       5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //9       5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //10      5.00    0               0.00    0.00            5.00            5.00            5.01            4.99
            //11      5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //12      5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //13      5.00    0               0.00    0.02            5.00            5.00            5.01            4.99
            //14      5.00    0               0.00    0.07            5.00            5.00            5.01            4.99
            //15      5.00    0               0.00    0.08            5.00            5.00            5.01            4.99
            //16      5.00    0               0.00    0.02            5.00            5.00            5.01            4.99
            //17      5.00    0               0.00    0.05            5.00            5.00            5.01            4.99
            //18      5.00    0               0.00    0.12            5.00            5.00            5.01            4.99
            //19      5.00    0               0.00    0.17            5.00            5.00            5.01            4.99
            //20      10.00   1               0.50    0.80            5.00            5.00            5.01            4.99
            //21      5.00    0               0.00    0.16            5.00            5.00            5.01            4.99
            //22      5.00    0               0.00    0.11            5.00            5.00            5.01            4.99
            //23      5.00    0               0.00    0.05            5.00            5.00            5.01            4.99
            //24      5.00    0               0.00    0.11            5.00            5.00            5.01            4.99
            //25      5.00    0               0.00    0.19            5.00            5.00            5.01            4.99
        }

        private static void PrintPrediction(int idx, double value, SrCnnAnomalyDetection prediction) =>
            Console.WriteLine("{0}\t{1:0.00}\t{2}\t\t{3:0.00}\t{4:0.00}\t\t{5:0.00}\t\t{6:0.00}\t\t{7:0.00}\t\t{8:0.00}",
                idx, value, prediction.Prediction[0], prediction.Prediction[1], prediction.Prediction[2],
                prediction.Prediction[3], prediction.Prediction[4], prediction.Prediction[5], prediction.Prediction[6]);

        private class TimeSeriesData
        {
            public double Value { get; set; }
        }

        private class SrCnnAnomalyDetection
        {
            [VectorType]
            public double[] Prediction { get; set; }
        }
    }
}

適用対象

DetectEntireAnomalyBySrCnn(AnomalyDetectionCatalog, IDataView, String, String, Double, Int32, Double, SrCnnDetectMode)

SRCNN アルゴリズムを使用して入力全体の時系列の異常を検出する Create Microsoft.ML.TimeSeries.SrCnnEntireAnomalyDetector

public static Microsoft.ML.IDataView DetectEntireAnomalyBySrCnn (this Microsoft.ML.AnomalyDetectionCatalog catalog, Microsoft.ML.IDataView input, string outputColumnName, string inputColumnName, double threshold = 0.3, int batchSize = 1024, double sensitivity = 99, Microsoft.ML.TimeSeries.SrCnnDetectMode detectMode = Microsoft.ML.TimeSeries.SrCnnDetectMode.AnomalyOnly);
static member DetectEntireAnomalyBySrCnn : Microsoft.ML.AnomalyDetectionCatalog * Microsoft.ML.IDataView * string * string * double * int * double * Microsoft.ML.TimeSeries.SrCnnDetectMode -> Microsoft.ML.IDataView
<Extension()>
Public Function DetectEntireAnomalyBySrCnn (catalog As AnomalyDetectionCatalog, input As IDataView, outputColumnName As String, inputColumnName As String, Optional threshold As Double = 0.3, Optional batchSize As Integer = 1024, Optional sensitivity As Double = 99, Optional detectMode As SrCnnDetectMode = Microsoft.ML.TimeSeries.SrCnnDetectMode.AnomalyOnly) As IDataView

パラメーター

catalog
AnomalyDetectionCatalog

AnomalyDetectionCatalog。

input
IDataView

DataView を入力します。

outputColumnName
String

のデータ処理に起因する列の inputColumnName名前。 列データは次のベクトルです Double。 このベクトルの長さはによって異なります detectMode

inputColumnName
String

処理する列の名前。 列データは次の値にする Double必要があります。

threshold
Double

異常を特定するためのしきい値。 特定のポイントの計算された SR 生スコアが設定されたしきい値を超えると、異常が検出されます。 このしきい値は [0,1] の間で指定する必要があり、既定値は 0.3 です。

batchSize
Int32

srcnn モデルに合わせて入力データをバッチに分割します。 -1 に設定した場合は、バッチ単位ではなくモデルに合わせて入力全体を使用します。正の整数に設定した場合は、この数値をバッチ サイズとして使用します。 -1 または 12 未満の正の整数である必要があります。 既定値は 1024 です。

sensitivity
Double

境界の秘密度。srCnnDetectMode が AnomalyAndMargin の場合にのみ役立ちます。 [0,100] である必要があります。 既定値は 99 です。

detectMode
SrCnnDetectMode

の列挙型 SrCnnDetectMode。 AnomalyOnly に設定すると、出力ベクトルは 3 要素の Double ベクター (IsAnomaly、RawScore、Mag) になります。 AnomalyAndExpectedValue に設定すると、出力ベクトルは (IsAnomaly、RawScore、Mag、ExpectedValue) の 4 要素 Double ベクターになります。 AnomalyAndMargin に設定すると、出力ベクトルは 7 要素の Double ベクター (IsAnomaly、AnomalyScore、Mag、ExpectedValue、BoundaryUnit、UpperBoundary、LowerBoundary) になります。 RawScore は SR によって出力され、ポイントが異常であるかどうかを判断します。AnomalyAndMargin モードでは、ポイントが異常である場合、AnomalyScore は秘密度設定に従って計算されます。 既定値は AnomalyOnly です。

戻り値

using System;
using System.Collections.Generic;
using Microsoft.ML;
using Microsoft.ML.Data;
using Microsoft.ML.TimeSeries;

namespace Samples.Dynamic
{
    public static class DetectEntireAnomalyBySrCnn
    {
        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 an anomaly
            var data = new List<TimeSeriesData>();
            for (int index = 0; index < 20; index++)
            {
                data.Add(new TimeSeriesData { Value = 5 });
            }
            data.Add(new TimeSeriesData { Value = 10 });
            for (int index = 0; index < 5; index++)
            {
                data.Add(new TimeSeriesData { Value = 5 });
            }

            // Convert data to IDataView.
            var dataView = ml.Data.LoadFromEnumerable(data);

            // Setup the detection arguments
            string outputColumnName = nameof(SrCnnAnomalyDetection.Prediction);
            string inputColumnName = nameof(TimeSeriesData.Value);

            // Do batch anomaly detection
            var outputDataView = ml.AnomalyDetection.DetectEntireAnomalyBySrCnn(dataView, outputColumnName, inputColumnName,
                threshold: 0.35, batchSize: 512, sensitivity: 90.0, detectMode: SrCnnDetectMode.AnomalyAndMargin);

            // Getting the data of the newly created column as an IEnumerable of
            // SrCnnAnomalyDetection.
            var predictionColumn = ml.Data.CreateEnumerable<SrCnnAnomalyDetection>(
                outputDataView, reuseRowObject: false);

            Console.WriteLine("Index\tData\tAnomaly\tAnomalyScore\tMag\tExpectedValue\tBoundaryUnit\tUpperBoundary\tLowerBoundary");

            int k = 0;
            foreach (var prediction in predictionColumn)
            {
                PrintPrediction(k, data[k].Value, prediction);
                k++;
            }
            //Index Data    Anomaly AnomalyScore    Mag ExpectedValue   BoundaryUnit UpperBoundary   LowerBoundary
            //0       5.00    0               0.00    0.21            5.00            5.00            5.01            4.99
            //1       5.00    0               0.00    0.11            5.00            5.00            5.01            4.99
            //2       5.00    0               0.00    0.03            5.00            5.00            5.01            4.99
            //3       5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //4       5.00    0               0.00    0.03            5.00            5.00            5.01            4.99
            //5       5.00    0               0.00    0.06            5.00            5.00            5.01            4.99
            //6       5.00    0               0.00    0.02            5.00            5.00            5.01            4.99
            //7       5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //8       5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //9       5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //10      5.00    0               0.00    0.00            5.00            5.00            5.01            4.99
            //11      5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //12      5.00    0               0.00    0.01            5.00            5.00            5.01            4.99
            //13      5.00    0               0.00    0.02            5.00            5.00            5.01            4.99
            //14      5.00    0               0.00    0.07            5.00            5.00            5.01            4.99
            //15      5.00    0               0.00    0.08            5.00            5.00            5.01            4.99
            //16      5.00    0               0.00    0.02            5.00            5.00            5.01            4.99
            //17      5.00    0               0.00    0.05            5.00            5.00            5.01            4.99
            //18      5.00    0               0.00    0.12            5.00            5.00            5.01            4.99
            //19      5.00    0               0.00    0.17            5.00            5.00            5.01            4.99
            //20      10.00   1               0.50    0.80            5.00            5.00            5.01            4.99
            //21      5.00    0               0.00    0.16            5.00            5.00            5.01            4.99
            //22      5.00    0               0.00    0.11            5.00            5.00            5.01            4.99
            //23      5.00    0               0.00    0.05            5.00            5.00            5.01            4.99
            //24      5.00    0               0.00    0.11            5.00            5.00            5.01            4.99
            //25      5.00    0               0.00    0.19            5.00            5.00            5.01            4.99
        }

        private static void PrintPrediction(int idx, double value, SrCnnAnomalyDetection prediction) =>
            Console.WriteLine("{0}\t{1:0.00}\t{2}\t\t{3:0.00}\t{4:0.00}\t\t{5:0.00}\t\t{6:0.00}\t\t{7:0.00}\t\t{8:0.00}",
                idx, value, prediction.Prediction[0], prediction.Prediction[1], prediction.Prediction[2],
                prediction.Prediction[3], prediction.Prediction[4], prediction.Prediction[5], prediction.Prediction[6]);

        private class TimeSeriesData
        {
            public double Value { get; set; }
        }

        private class SrCnnAnomalyDetection
        {
            [VectorType]
            public double[] Prediction { get; set; }
        }
    }
}

適用対象