Skip to content

Commit 5819330

Browse files
committed
TimeSeries - make catalog API methods with int confidence parameter deprecated.
- Tests adjusted to not use the deprecated methods
1 parent 26e248a commit 5819330

11 files changed

+17
-13
lines changed

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/DetectChangePointBySsa.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void Example()
5252
// Setup SsaChangePointDetector arguments
5353
var inputColumnName = nameof(TimeSeriesData.Value);
5454
var outputColumnName = nameof(ChangePointPrediction.Prediction);
55-
int confidence = 95;
55+
double confidence = 95;
5656
int changeHistoryLength = 8;
5757

5858
// Train the change point detector.

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/DetectChangePointBySsaBatchPrediction.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void Example()
5959

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

6565
// Getting the data of the newly created column as an IEnumerable of

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/DetectChangePointBySsaStream.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void Example()
5252
// Setup SsaChangePointDetector arguments
5353
var inputColumnName = nameof(TimeSeriesData.Value);
5454
var outputColumnName = nameof(ChangePointPrediction.Prediction);
55-
int confidence = 95;
55+
double confidence = 95;
5656
int changeHistoryLength = 8;
5757

5858
// Train the change point detector.

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/DetectIidChangePoint.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static void Example()
5555

5656
// Time Series model.
5757
ITransformer model = ml.Transforms.DetectIidChangePoint(
58-
outputColumnName, inputColumnName, 95, Size / 4).Fit(dataView);
58+
outputColumnName, inputColumnName, 95.0d, Size / 4).Fit(dataView);
5959

6060
// Create a time series prediction engine from the model.
6161
var engine = model.CreateTimeSeriesEngine<TimeSeriesData,

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/DetectIidChangePointBatchPrediction.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void Example()
5353

5454
// The transformed data.
5555
var transformedData = ml.Transforms.DetectIidChangePoint(
56-
outputColumnName, inputColumnName, 95, Size / 4).Fit(dataView)
56+
outputColumnName, inputColumnName, 95.0d, Size / 4).Fit(dataView)
5757
.Transform(dataView);
5858

5959
// Getting the data of the newly created column as an IEnumerable of

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/DetectIidSpike.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void Example()
4747

4848
// The transformed model.
4949
ITransformer model = ml.Transforms.DetectIidSpike(outputColumnName,
50-
inputColumnName, 95, Size).Fit(dataView);
50+
inputColumnName, 95.0d, Size).Fit(dataView);
5151

5252
// Create a time series prediction engine from the model.
5353
var engine = model.CreateTimeSeriesEngine<TimeSeriesData,

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/DetectIidSpikeBatchPrediction.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void Example()
4545

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

5050
// Getting the data of the newly created column as an IEnumerable of
5151
// IidSpikePrediction.

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/DetectSpikeBySsa.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void Example()
5353

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

5959
// Create a prediction engine from the model for feeding new data.

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/TimeSeries/DetectSpikeBySsaBatchPrediction.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void Example()
6161

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

6767
// Getting the data of the newly created column as an IEnumerable of

src/Microsoft.ML.TimeSeries/ExtensionsCatalog.cs

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public static class TimeSeriesCatalog
3333
/// ]]>
3434
/// </format>
3535
/// </example>
36+
[Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")]
3637
public static IidChangePointEstimator DetectIidChangePoint(this TransformsCatalog catalog, string outputColumnName, string inputColumnName,
3738
int confidence, int changeHistoryLength, MartingaleType martingale = MartingaleType.Power, double eps = 0.1)
3839
=> DetectIidChangePoint(catalog, outputColumnName, inputColumnName, (double)confidence, changeHistoryLength, martingale, eps);
@@ -81,6 +82,7 @@ public static IidChangePointEstimator DetectIidChangePoint(this TransformsCatalo
8182
/// ]]>
8283
/// </format>
8384
/// </example>
85+
[Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")]
8486
public static IidSpikeEstimator DetectIidSpike(this TransformsCatalog catalog, string outputColumnName, string inputColumnName,
8587
int confidence, int pvalueHistoryLength, AnomalySide side = AnomalySide.TwoSided)
8688
=> DetectIidSpike(catalog, outputColumnName, inputColumnName, (double)confidence, pvalueHistoryLength, side);
@@ -132,6 +134,7 @@ public static IidSpikeEstimator DetectIidSpike(this TransformsCatalog catalog, s
132134
/// ]]>
133135
/// </format>
134136
/// </example>
137+
[Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")]
135138
public static SsaChangePointEstimator DetectChangePointBySsa(this TransformsCatalog catalog, string outputColumnName, string inputColumnName,
136139
int confidence, int changeHistoryLength, int trainingWindowSize, int seasonalityWindowSize, ErrorFunction errorFunction = ErrorFunction.SignedDifference,
137140
MartingaleType martingale = MartingaleType.Power, double eps = 0.1)
@@ -198,6 +201,7 @@ public static SsaChangePointEstimator DetectChangePointBySsa(this TransformsCata
198201
/// ]]>
199202
/// </format>
200203
/// </example>
204+
[Obsolete("This API method is deprecated, please use the overload with confidence parameter of type double.")]
201205
public static SsaSpikeEstimator DetectSpikeBySsa(this TransformsCatalog catalog, string outputColumnName, string inputColumnName, int confidence, int pvalueHistoryLength,
202206
int trainingWindowSize, int seasonalityWindowSize, AnomalySide side = AnomalySide.TwoSided, ErrorFunction errorFunction = ErrorFunction.SignedDifference)
203207
=> DetectSpikeBySsa(catalog, outputColumnName, inputColumnName, (double)confidence, pvalueHistoryLength, trainingWindowSize, seasonalityWindowSize, side, errorFunction);

test/Microsoft.ML.TimeSeries.Tests/TimeSeriesSimpleApiTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void ChangeDetection()
4848
data.Add(new Data((float)(5 + i * 1.1)));
4949

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

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

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

135135
// Build the pipeline
136-
var learningPipeline = ML.Transforms.DetectIidSpike("Data", "Value", 80, pvalHistoryLength);
136+
var learningPipeline = ML.Transforms.DetectIidSpike("Data", "Value", 80.0d, pvalHistoryLength);
137137
// Train
138138
var detector = learningPipeline.Fit(dataView);
139139
// Transform
@@ -185,7 +185,7 @@ public void SsaSpikeDetection()
185185
data.Add(new Data(5));
186186

187187
// Build the pipeline
188-
var learningPipeline = ML.Transforms.DetectSpikeBySsa("Data", "Value", 80, changeHistoryLength, trainingWindowSize, seasonalityWindowSize);
188+
var learningPipeline = ML.Transforms.DetectSpikeBySsa("Data", "Value", 80.0d, changeHistoryLength, trainingWindowSize, seasonalityWindowSize);
189189
// Train
190190
var detector = learningPipeline.Fit(dataView);
191191
// Transform

0 commit comments

Comments
 (0)