コード例 #1
0
 /// <summary>
 /// Create a new instance of <see cref="SsaChangePointEstimator"/>
 /// </summary>
 /// <param name="env">Host Environment.</param>
 /// <param name="inputColumn">Name of the input column.</param>
 /// <param name="outputColumn">Name of the output column.</param>
 /// <param name="confidence">The confidence for change point detection in the range [0, 100].</param>
 /// <param name="trainingWindowSize">The number of points from the beginning of the sequence used for training.</param>
 /// <param name="changeHistoryLength">The size of the sliding window for computing the p-value.</param>
 /// <param name="seasonalityWindowSize">An upper bound on the largest relevant seasonality in the input time-series.</param>
 /// <param name="errorFunction">The function used to compute the error between the expected and the observed value.</param>
 /// <param name="martingale">The martingale used for scoring.</param>
 /// <param name="eps">The epsilon parameter for the Power martingale.</param>
 /// <p>Example code can be found by searching for <i>SsaChangePointDetector</i> in <a href='https://github.com/dotnet/machinelearning'>ML.NET.</a></p>
 /// <example>
 /// <format type="text/markdown">
 /// <![CDATA[
 /// [!code-csharp[MF](~/../docs/samples/docs/samples/Microsoft.ML.Samples/Dynamic/Timeseries.cs?range=6-12,17-37,167-229)]
 /// ]]>
 /// </format>
 /// </example>
 public SsaChangePointEstimator(IHostEnvironment env, string inputColumn, string outputColumn,
                                int confidence, int changeHistoryLength, int trainingWindowSize, int seasonalityWindowSize,
                                ErrorFunctionUtils.ErrorFunction errorFunction = ErrorFunctionUtils.ErrorFunction.SignedDifference,
                                MartingaleType martingale = MartingaleType.Power, double eps = 0.1)
     : this(env, new SsaChangePointDetector.Arguments
 {
     Name = outputColumn,
     Source = inputColumn,
     Confidence = confidence,
     ChangeHistoryLength = changeHistoryLength,
     TrainingWindowSize = trainingWindowSize,
     SeasonalWindowSize = seasonalityWindowSize,
     Martingale = martingale,
     PowerMartingaleEpsilon = eps,
     ErrorFunction = errorFunction
 })
 {
 }
コード例 #2
0
        public SsaAnomalyDetectionBase(SsaArguments args, string name, IHostEnvironment env)
            : base(args.WindowSize, 0, args.Source, args.Name, name, env, args.Side, args.Martingale, args.AlertOn, args.PowerMartingaleEpsilon, args.AlertThreshold)
        {
            Host.CheckUserArg(2 <= args.SeasonalWindowSize, nameof(args.SeasonalWindowSize), "Must be at least 2.");
            Host.CheckUserArg(0 <= args.DiscountFactor && args.DiscountFactor <= 1, nameof(args.DiscountFactor), "Must be in the range [0, 1].");
            Host.CheckUserArg(Enum.IsDefined(typeof(ErrorFunctionUtils.ErrorFunction), args.ErrorFunction), nameof(args.ErrorFunction), ErrorFunctionUtils.ErrorFunctionHelpText);

            SeasonalWindowSize = args.SeasonalWindowSize;
            DiscountFactor     = args.DiscountFactor;
            ErrorFunction      = args.ErrorFunction;
            ErrorFunc          = ErrorFunctionUtils.GetErrorFunction(ErrorFunction);
            IsAdaptive         = args.IsAdaptive;
            // Creating the master SSA model
            Model = new AdaptiveSingularSpectrumSequenceModeler(Host, args.InitialWindowSize, SeasonalWindowSize + 1, SeasonalWindowSize,
                                                                DiscountFactor, AdaptiveSingularSpectrumSequenceModeler.RankSelectionMethod.Exact, null, SeasonalWindowSize / 2, false, false);

            StateRef = new State();
            StateRef.InitState(WindowSize, InitialWindowSize, this, Host);
        }
コード例 #3
0
 /// <summary>
 /// Create a new instance of <see cref="SsaSpikeEstimator"/>
 /// </summary>
 /// <param name="env">Host Environment.</param>
 /// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnName"/>.</param>
 /// <param name="confidence">The confidence for spike detection in the range [0, 100].</param>
 /// <param name="pvalueHistoryLength">The size of the sliding window for computing the p-value.</param>
 /// <param name="trainingWindowSize">The number of points from the beginning of the sequence used for training.</param>
 /// <param name="seasonalityWindowSize">An upper bound on the largest relevant seasonality in the input time-series.</param>
 /// <param name="inputColumnName">Name of column to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.
 /// The vector contains Alert, Raw Score, P-Value as first three values.</param>
 /// <param name="side">The argument that determines whether to detect positive or negative anomalies, or both.</param>
 /// <param name="errorFunction">The function used to compute the error between the expected and the observed value.</param>
 public SsaSpikeEstimator(IHostEnvironment env,
                          string outputColumnName,
                          int confidence,
                          int pvalueHistoryLength,
                          int trainingWindowSize,
                          int seasonalityWindowSize,
                          string inputColumnName = null,
                          AnomalySide side       = AnomalySide.TwoSided,
                          ErrorFunctionUtils.ErrorFunction errorFunction = ErrorFunctionUtils.ErrorFunction.SignedDifference)
     : this(env, new SsaSpikeDetector.Arguments
 {
     Source = inputColumnName ?? outputColumnName,
     Name = outputColumnName,
     Confidence = confidence,
     PvalueHistoryLength = pvalueHistoryLength,
     TrainingWindowSize = trainingWindowSize,
     SeasonalWindowSize = seasonalityWindowSize,
     Side = side,
     ErrorFunction = errorFunction
 })
 {
 }