Skip to content

Commit 5c538cd

Browse files
committed
Update test baseline for TimeSeries tests
1 parent 81035c3 commit 5c538cd

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void SavePipeSsaSpike()
7373
Done();
7474
}
7575

76-
[LessThanNetCore30OrNotNetCoreFact("netcoreapp3.0 output differs from Baseline")]
76+
[Fact]
7777
public void SavePipeSsaSpikeNoData()
7878
{
7979
string pathData = DeleteOutputPath("SavePipe", "SsaSpikeNoData.txt");

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

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@
55
using System.Collections.Generic;
66
using System.IO;
77
using Microsoft.ML.Data;
8+
using Microsoft.ML.TestFramework;
89
using Microsoft.ML.TestFramework.Attributes;
910
using Microsoft.ML.Transforms.TimeSeries;
1011
using Xunit;
12+
using Xunit.Abstractions;
1113

1214
namespace Microsoft.ML.Tests
1315
{
14-
public sealed class TimeSeries
16+
public sealed class TimeSeries : BaseTestClass
1517
{
18+
public TimeSeries(ITestOutputHelper output)
19+
: base(output)
20+
{
21+
}
1622

1723
private sealed class Prediction
1824
{
@@ -126,7 +132,7 @@ public void ChangeDetection()
126132
}
127133
}
128134

129-
[LessThanNetCore30OrNotNetCoreFact("netcoreapp3.0 output differs from Baseline")]
135+
[Fact]
130136
public void ChangePointDetectionWithSeasonality()
131137
{
132138
var env = new MLContext();
@@ -162,8 +168,13 @@ public void ChangePointDetectionWithSeasonality()
162168
// Get predictions
163169
var enumerator = env.Data.CreateEnumerable<Prediction>(output, true).GetEnumerator();
164170
Prediction row = null;
171+
#if NETCOREAPP3_0
172+
List<double> expectedValues = new List<double>() { 0, -3.31410551071167, 0.5, 5.12000000000001E-08, 0, 1.570083498954773, 5.2001145245395008E-07,
173+
0.012414560443710681, 0, 1.2854313850402832, 0.2881081472302483, 0.020389485008225454, 0, -1.0950632095336914, 0.3666388047550645, 0.02695657272695535};
174+
#else
165175
List<double> expectedValues = new List<double>() { 0, -3.31410598754883, 0.5, 5.12000000000001E-08, 0, 1.5700820684432983, 5.2001145245395008E-07,
166176
0.012414560443710681, 0, 1.2854313254356384, 0.28810801662678009, 0.02038940454467935, 0, -1.0950627326965332, 0.36663890634019225, 0.026956459625565483};
177+
#endif
167178

168179
int index = 0;
169180
while (enumerator.MoveNext() && index < expectedValues.Count)
@@ -176,7 +187,7 @@ public void ChangePointDetectionWithSeasonality()
176187
}
177188
}
178189

179-
[LessThanNetCore30OrNotNetCoreFact("netcoreapp3.0 output differs from Baseline")]
190+
[Fact]
180191
public void ChangePointDetectionWithSeasonalityPredictionEngineNoColumn()
181192
{
182193
const int ChangeHistorySize = 10;
@@ -252,7 +263,7 @@ public void ChangePointDetectionWithSeasonalityPredictionEngineNoColumn()
252263
Assert.Equal(0.12216401100158691, prediction2.Change[1], precision: 5); // Raw score
253264
}
254265

255-
[LessThanNetCore30OrNotNetCoreFact("netcoreapp3.0 output differs from Baseline")]
266+
[Fact]
256267
public void ChangePointDetectionWithSeasonalityPredictionEngine()
257268
{
258269
const int ChangeHistorySize = 10;
@@ -322,7 +333,7 @@ public void ChangePointDetectionWithSeasonalityPredictionEngine()
322333
Assert.Equal(1.5292508189989167E-07, prediction.Change[3], precision: 5); // Martingale score
323334
}
324335

325-
[LessThanNetCore30OrNotNetCoreFact("netcoreapp3.0 output differs from Baseline")]
336+
[Fact]
326337
public void SsaForecast()
327338
{
328339
var env = new MLContext();
@@ -361,9 +372,15 @@ public void SsaForecast()
361372
// Get predictions
362373
var enumerator = env.Data.CreateEnumerable<ForecastPrediction>(output, true).GetEnumerator();
363374
ForecastPrediction row = null;
375+
#if NETCOREAPP3_0
376+
List<float> expectedForecast = new List<float>() { 0.191492021f, 2.53994060f, 5.26454258f, 7.37313938f };
377+
List<float> minCnf = new List<float>() { -3.9741986f, -2.36872721f, 0.09407699f, 2.18899393f };
378+
List<float> maxCnf = new List<float>() { 4.3571825f, 7.4486084f, 10.435008f, 12.5572853f };
379+
#else
364380
List<float> expectedForecast = new List<float>() { 0.191491723f, 2.53994083f, 5.26454258f, 7.37313938f };
365381
List<float> minCnf = new List<float>() { -3.9741993f, -2.36872721f, 0.09407653f, 2.18899345f };
366382
List<float> maxCnf = new List<float>() { 4.3571825f, 7.448609f, 10.435009f, 12.5572853f };
383+
#endif
367384
enumerator.MoveNext();
368385
row = enumerator.Current;
369386

@@ -376,7 +393,7 @@ public void SsaForecast()
376393

377394
}
378395

379-
[LessThanNetCore30OrNotNetCoreFact("netcoreapp3.0 output differs from Baseline")]
396+
[Fact]
380397
public void SsaForecastPredictionEngine()
381398
{
382399
const int ChangeHistorySize = 10;
@@ -425,8 +442,13 @@ public void SsaForecastPredictionEngine()
425442
// Forecast and change the horizon to 5.
426443
engine.Predict(null, ref result, horizon: 5);
427444
// [Forecast, ConfidenceLowerBound, ConfidenceUpperBound]
428-
Assert.Equal(result.Forecast, new float[] { -1.02245092f, 0.08333081f, 2.60737085f, 5.397319f, 7.500832f, -5.188142f, -4.82533741f,
429-
-2.563095f, 0.213172823f, 2.29317045f, 3.14324f, 4.991999f, 7.777837f, 10.5814648f, 12.7084932f });
445+
#if NETCOREAPP3_0
446+
Assert.Equal(new float[] { -1.02245092f, 0.08333033f, 2.6073704f, 5.397318f, 7.5008316f, -5.1881413f, -4.82533741f,
447+
-2.563095f, 0.21317233f, 2.29317045f, 3.1432397f, 4.991998f, 7.777836f, 10.581464f, 12.708492f }, result.Forecast);
448+
#else
449+
Assert.Equal(new float[] { -1.02245092f, 0.08333081f, 2.60737085f, 5.397319f, 7.500832f, -5.188142f, -4.82533741f,
450+
-2.563095f, 0.213172823f, 2.29317045f, 3.14324f, 4.991999f, 7.777837f, 10.5814648f, 12.7084932f }, result.Forecast);
451+
#endif
430452

431453
// Update the forecasting model.
432454
engine.Predict(new Data(2));
@@ -436,8 +458,13 @@ public void SsaForecastPredictionEngine()
436458

437459
engine.CheckPoint(ml, "model.zip");
438460
// [Forecast, ConfidenceLowerBound, ConfidenceUpperBound]
439-
Assert.Equal(result.Forecast, new float[] { 4.310587f, 6.39716768f, 7.73934f, 8.029469f, 0.144895911f,
440-
1.48849952f, 2.568874f, 2.84532261f, 8.476278f, 11.3058357f, 12.9098063f, 13.2136145f });
461+
#if NETCOREAPP3_0
462+
Assert.Equal(new float[] { 4.310586f, 6.397167f, 7.73934f, 8.029469f, 0.14489543f,
463+
1.48849952f, 2.5688744f, 2.845323f, 8.476276f, 11.305835f, 12.909805f, 13.2136145f }, result.Forecast);
464+
#else
465+
Assert.Equal(new float[] { 4.310587f, 6.39716768f, 7.73934f, 8.029469f, 0.144895911f,
466+
1.48849952f, 2.568874f, 2.84532261f, 8.476278f, 11.3058357f, 12.9098063f, 13.2136145f }, result.Forecast);
467+
#endif
441468

442469
// Checkpoint the model.
443470
ITransformer modelCopy;
@@ -456,9 +483,15 @@ public void SsaForecastPredictionEngine()
456483
forecastEngineCopy.Predict(null, ref resultCopy, horizon: 5);
457484
engine.Predict(null, ref result, horizon: 5);
458485
// [Forecast, ConfidenceLowerBound, ConfidenceUpperBound]
459-
Assert.Equal(result.Forecast, new float[] { 6.00658846f, 7.506871f, 7.96424866f, 7.17514229f,
486+
#if NETCOREAPP3_0
487+
Assert.Equal(new float[] { 6.006588f, 7.506871f, 7.964249f, 7.1751432f,
488+
5.0265527f, 1.84089744f, 2.5982034f, 2.7937837f, 1.9909977f,
489+
-0.1811084f, 10.172278f, 12.415539f, 13.1347151f, 12.359289f, 10.234214f}, result.Forecast);
490+
#else
491+
Assert.Equal(new float[] { 6.00658846f, 7.506871f, 7.96424866f, 7.17514229f,
460492
5.02655172f, 1.84089744f, 2.59820318f, 2.79378271f, 1.99099624f,
461-
-0.181109816f, 10.1722794f, 12.41554f, 13.1347151f, 12.3592882f, 10.2342129f});
493+
-0.181109816f, 10.1722794f, 12.41554f, 13.1347151f, 12.3592882f, 10.2342129f}, result.Forecast);
494+
#endif
462495

463496
// The forecasted results should be the same because the state of the models
464497
// is the same.

0 commit comments

Comments
 (0)