TimeSeriesCatalog.DetectSeasonality 메서드

정의

시계열 데이터에서 계절성(또는 주기성)은 매주, 매월 또는 분기별와 같은 특정 정기적인 간격으로 발생하는 변형의 존재입니다.

이 메서드는 푸리에 분석 기술을 채택하여 예측 가능한 간격(또는 마침표)을 검색합니다. 입력 값이 동일한 시간 간격(예: 타임스탬프별로 매 초마다 수집되는 센서 데이터)을 갖는 경우 이 메서드는 시계열 데이터 목록을 사용하고 입력 계절 데이터의 정규 기간을 반환합니다. 예측 가능한 변동 또는 패턴이 입력 값 전체에서 이 기간 동안 재귀하거나 반복되는 것을 발견할 수 있는 경우.

이러한 패턴이 없으면 -1을 반환합니다. 즉, 입력 값이 계절적 변동을 따르지 않습니다.

public static int DetectSeasonality (this Microsoft.ML.AnomalyDetectionCatalog catalog, Microsoft.ML.IDataView input, string inputColumnName, int seasonalityWindowSize = -1, double randomnessThreshold = 0.95);
static member DetectSeasonality : Microsoft.ML.AnomalyDetectionCatalog * Microsoft.ML.IDataView * string * int * double -> int
<Extension()>
Public Function DetectSeasonality (catalog As AnomalyDetectionCatalog, input As IDataView, inputColumnName As String, Optional seasonalityWindowSize As Integer = -1, Optional randomnessThreshold As Double = 0.95) As Integer

매개 변수

catalog
AnomalyDetectionCatalog

계절성 검색 카탈로그입니다.

input
IDataView

Input DataView.데이터는 .의 IDataView인스턴스입니다.

inputColumnName
String

처리할 열의 이름입니다. 열 데이터는 .이어야 Double합니다.

seasonalityWindowSize
Int32

입력 값에서 고려할 값 수의 상한입니다. -1로 설정하면 전체 입력을 사용하여 모델에 맞습니다. 양수 정수로 설정하면 첫 번째 windowSize 값 수만 고려됩니다. 기본값은 -1입니다.

randomnessThreshold
Double

입력 값이 계절 데이터로 되풀이되는 예측 가능한 패턴을 얼마나 자신 있게 따르는지를 지정하는 임의성 임계값입니다. 범위는 [0, 1] 사이입니다. 기본적으로 0.95로 설정됩니다.

반환

입력에 대한 정규 간격을 계절 데이터로 지정하고, 그렇지 않으면 -1을 반환합니다.

예제

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

namespace Samples.Dynamic
{
    public static class DetectSeasonality
    {
        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 mlContext = new MLContext();

            // Create a seasonal data as input: y = sin(2 * Pi + x)
            var seasonalData = Enumerable.Range(0, 100).Select(x => new TimeSeriesData(Math.Sin(2 * Math.PI + x)));

            // Load the input data as a DataView.
            var dataView = mlContext.Data.LoadFromEnumerable(seasonalData);

            /* Two option parameters:
             * seasonalityWindowSize: Default value is -1. When set to -1, use the whole input to fit model; 
             * when set to a positive integer, only the first windowSize number of values will be considered.
             * randomnessThreshold: Randomness threshold that specifies how confidence the input values follows 
             * a predictable pattern recurring as seasonal data. By default, it is set as 0.99. 
             * The higher the threshold is set, the more strict recurring pattern the 
             * input values should follow to be determined as seasonal data.
             */
            int period = mlContext.AnomalyDetection.DetectSeasonality(
                dataView,
                nameof(TimeSeriesData.Value),
                seasonalityWindowSize: 40);

            // Print the Seasonality Period result.
            Console.WriteLine($"Seasonality Period: #{period}");
        }

        private class TimeSeriesData
        {
            public double Value;

            public TimeSeriesData(double value)
            {
                Value = value;
            }
        }

    }
}

적용 대상