TimeSeriesCatalog.DetectEntireAnomalyBySrCnn 메서드

정의

오버로드

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

SRCNN 알고리즘을 사용하여 전체 입력에 대한 시간 변칙을 검색하는 를 만듭니 Microsoft.ML.TimeSeries.SrCnnEntireAnomalyDetector다.

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

SRCNN 알고리즘을 사용하여 전체 입력에 대한 시간 변칙을 검색하는 를 만듭니 Microsoft.ML.TimeSeries.SrCnnEntireAnomalyDetector다.

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

SRCNN 알고리즘을 사용하여 전체 입력에 대한 시간 변칙을 검색하는 를 만듭니 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

Input 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 알고리즘을 사용하여 전체 입력에 대한 시간 변칙을 검색하는 를 만듭니 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

Input 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개 요소의 이중 벡터(IsAnomaly, RawScore, Mag)가 됩니다. AnomalyAndExpectedValue로 설정하면 출력 벡터는 4개 요소의 이중 벡터(IsAnomaly, RawScore, Mag, ExpectedValue)가 됩니다. AnomalyAndMargin으로 설정하면 출력 벡터는 7개 요소의 이중 벡터(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; }
        }
    }
}

적용 대상