Skip to content

Commit

Permalink
TimeSeries - make catalog API methods with int confidence parameter d…
Browse files Browse the repository at this point in the history
…eprecated.

- Tests adjusted to not use the deprecated methods
  • Loading branch information
esso23 committed Feb 17, 2021
1 parent 26e248a commit 5819330
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void Example()
// Setup SsaChangePointDetector arguments
var inputColumnName = nameof(TimeSeriesData.Value);
var outputColumnName = nameof(ChangePointPrediction.Prediction);
int confidence = 95;
double confidence = 95;
int changeHistoryLength = 8;

// Train the change point detector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void Example()

// The transformed data.
var transformedData = ml.Transforms.DetectChangePointBySsa(
outputColumnName, inputColumnName, 95, 8, TrainingSize,
outputColumnName, inputColumnName, 95.0d, 8, TrainingSize,
SeasonalitySize + 1).Fit(dataView).Transform(dataView);

// Getting the data of the newly created column as an IEnumerable of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void Example()
// Setup SsaChangePointDetector arguments
var inputColumnName = nameof(TimeSeriesData.Value);
var outputColumnName = nameof(ChangePointPrediction.Prediction);
int confidence = 95;
double confidence = 95;
int changeHistoryLength = 8;

// Train the change point detector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void Example()

// Time Series model.
ITransformer model = ml.Transforms.DetectIidChangePoint(
outputColumnName, inputColumnName, 95, Size / 4).Fit(dataView);
outputColumnName, inputColumnName, 95.0d, Size / 4).Fit(dataView);

// Create a time series prediction engine from the model.
var engine = model.CreateTimeSeriesEngine<TimeSeriesData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void Example()

// The transformed data.
var transformedData = ml.Transforms.DetectIidChangePoint(
outputColumnName, inputColumnName, 95, Size / 4).Fit(dataView)
outputColumnName, inputColumnName, 95.0d, Size / 4).Fit(dataView)
.Transform(dataView);

// Getting the data of the newly created column as an IEnumerable of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void Example()

// The transformed model.
ITransformer model = ml.Transforms.DetectIidSpike(outputColumnName,
inputColumnName, 95, Size).Fit(dataView);
inputColumnName, 95.0d, Size).Fit(dataView);

// Create a time series prediction engine from the model.
var engine = model.CreateTimeSeriesEngine<TimeSeriesData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void Example()

// The transformed data.
var transformedData = ml.Transforms.DetectIidSpike(outputColumnName,
inputColumnName, 95, Size / 4).Fit(dataView).Transform(dataView);
inputColumnName, 95.0d, Size / 4).Fit(dataView).Transform(dataView);

// Getting the data of the newly created column as an IEnumerable of
// IidSpikePrediction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void Example()

// Train the change point detector.
ITransformer model = ml.Transforms.DetectSpikeBySsa(outputColumnName,
inputColumnName, 95, 8, TrainingSize, SeasonalitySize + 1).Fit(
inputColumnName, 95.0d, 8, TrainingSize, SeasonalitySize + 1).Fit(
dataView);

// Create a prediction engine from the model for feeding new data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void Example()

// The transformed data.
var transformedData = ml.Transforms.DetectSpikeBySsa(outputColumnName,
inputColumnName, 95, 8, TrainingSize, SeasonalitySize + 1).Fit(
inputColumnName, 95.0d, 8, TrainingSize, SeasonalitySize + 1).Fit(
dataView).Transform(dataView);

// Getting the data of the newly created column as an IEnumerable of
Expand Down
4 changes: 4 additions & 0 deletions src/Microsoft.ML.TimeSeries/ExtensionsCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static class TimeSeriesCatalog
/// ]]>
/// </format>
/// </example>
[Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")]
public static IidChangePointEstimator DetectIidChangePoint(this TransformsCatalog catalog, string outputColumnName, string inputColumnName,
int confidence, int changeHistoryLength, MartingaleType martingale = MartingaleType.Power, double eps = 0.1)
=> DetectIidChangePoint(catalog, outputColumnName, inputColumnName, (double)confidence, changeHistoryLength, martingale, eps);
Expand Down Expand Up @@ -81,6 +82,7 @@ public static IidChangePointEstimator DetectIidChangePoint(this TransformsCatalo
/// ]]>
/// </format>
/// </example>
[Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")]
public static IidSpikeEstimator DetectIidSpike(this TransformsCatalog catalog, string outputColumnName, string inputColumnName,
int confidence, int pvalueHistoryLength, AnomalySide side = AnomalySide.TwoSided)
=> DetectIidSpike(catalog, outputColumnName, inputColumnName, (double)confidence, pvalueHistoryLength, side);
Expand Down Expand Up @@ -132,6 +134,7 @@ public static IidSpikeEstimator DetectIidSpike(this TransformsCatalog catalog, s
/// ]]>
/// </format>
/// </example>
[Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")]
public static SsaChangePointEstimator DetectChangePointBySsa(this TransformsCatalog catalog, string outputColumnName, string inputColumnName,
int confidence, int changeHistoryLength, int trainingWindowSize, int seasonalityWindowSize, ErrorFunction errorFunction = ErrorFunction.SignedDifference,
MartingaleType martingale = MartingaleType.Power, double eps = 0.1)
Expand Down Expand Up @@ -198,6 +201,7 @@ public static SsaChangePointEstimator DetectChangePointBySsa(this TransformsCata
/// ]]>
/// </format>
/// </example>
[Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")]
public static SsaSpikeEstimator DetectSpikeBySsa(this TransformsCatalog catalog, string outputColumnName, string inputColumnName, int confidence, int pvalueHistoryLength,
int trainingWindowSize, int seasonalityWindowSize, AnomalySide side = AnomalySide.TwoSided, ErrorFunction errorFunction = ErrorFunction.SignedDifference)
=> DetectSpikeBySsa(catalog, outputColumnName, inputColumnName, (double)confidence, pvalueHistoryLength, trainingWindowSize, seasonalityWindowSize, side, errorFunction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void ChangeDetection()
data.Add(new Data((float)(5 + i * 1.1)));

// Build the pipeline
var learningPipeline = ML.Transforms.DetectIidChangePoint("Data", "Value", 80, size);
var learningPipeline = ML.Transforms.DetectIidChangePoint("Data", "Value", 80.0d, size);

// Train
var detector = learningPipeline.Fit(dataView);
Expand Down Expand Up @@ -92,7 +92,7 @@ public void ChangePointDetectionWithSeasonality()
data.Add(new Data(i * 100));

// Build the pipeline
var learningPipeline = ML.Transforms.DetectChangePointBySsa("Data", "Value", 95, changeHistorySize, maxTrainingSize, seasonalitySize);
var learningPipeline = ML.Transforms.DetectChangePointBySsa("Data", "Value", 95.0d, changeHistorySize, maxTrainingSize, seasonalitySize);
// Train
var detector = learningPipeline.Fit(dataView);
// Transform
Expand Down Expand Up @@ -133,7 +133,7 @@ public void SpikeDetection()
data.Add(new Data(5));

// Build the pipeline
var learningPipeline = ML.Transforms.DetectIidSpike("Data", "Value", 80, pvalHistoryLength);
var learningPipeline = ML.Transforms.DetectIidSpike("Data", "Value", 80.0d, pvalHistoryLength);
// Train
var detector = learningPipeline.Fit(dataView);
// Transform
Expand Down Expand Up @@ -185,7 +185,7 @@ public void SsaSpikeDetection()
data.Add(new Data(5));

// Build the pipeline
var learningPipeline = ML.Transforms.DetectSpikeBySsa("Data", "Value", 80, changeHistoryLength, trainingWindowSize, seasonalityWindowSize);
var learningPipeline = ML.Transforms.DetectSpikeBySsa("Data", "Value", 80.0d, changeHistoryLength, trainingWindowSize, seasonalityWindowSize);
// Train
var detector = learningPipeline.Fit(dataView);
// Transform
Expand Down

0 comments on commit 5819330

Please sign in to comment.