public SrCnnEntireAnomalyDetector(IHostEnvironment env, IDataView input, string outputColumnName, string inputColumnName, SrCnnEntireAnomalyDetectorOptions options) : base(env, nameof(SrCnnEntireAnomalyDetector), input) { Host.CheckValue(outputColumnName, nameof(outputColumnName)); Host.CheckValue(inputColumnName, nameof(inputColumnName)); _inputColumnName = inputColumnName; Host.CheckValue(options, nameof(options)); CheckOptionArguments(options); _options = options; _outputLength = _outputLengthArray[(int)options.DetectMode]; _bindings = new Bindings(input.Schema, inputColumnName, outputColumnName, new VectorDataViewType(NumberDataViewType.Double, _outputLength)); }
private void CheckOptionArguments(SrCnnEntireAnomalyDetectorOptions options) { Host.CheckUserArg(options.Period >= 0, nameof(options.Period), "Must be an integer equal to or greater than 0."); Host.CheckUserArg(options.BatchSize == -1 || options.BatchSize >= MinBatchSize, nameof(options.BatchSize), "Must be -1 or no less than 12."); Host.CheckUserArg(options.BatchSize >= 4 * options.Period || options.BatchSize == -1 || options.Period == 0, nameof(options.BatchSize), "Must be at least four times the length of one period."); Host.CheckUserArg(options.Threshold >= 0 && options.Threshold <= 1, nameof(options.Threshold), "Must be in [0,1]."); Host.CheckUserArg(options.DetectMode == SrCnnDetectMode.AnomalyOnly || options.DetectMode == SrCnnDetectMode.AnomalyAndExpectedValue || options.DetectMode == SrCnnDetectMode.AnomalyAndMargin, nameof(options.DetectMode), "Invalid detectMode"); Host.CheckUserArg(options.DeseasonalityMode == SrCnnDeseasonalityMode.Stl || options.DeseasonalityMode == SrCnnDeseasonalityMode.Mean || options.DeseasonalityMode == SrCnnDeseasonalityMode.Median, nameof(options.DeseasonalityMode), "Invalid detectMode"); Host.CheckUserArg(options.Sensitivity >= 0 && options.Sensitivity <= 100, nameof(options.Sensitivity), "Must be in [0,100]."); }