From 03c01ac71d73bd90cbeb64af4608152c6b7b3191 Mon Sep 17 00:00:00 2001 From: Mustafa Bal Date: Thu, 20 Feb 2020 23:16:04 -0800 Subject: [PATCH] nrBinsFix and re-enabling related tests --- .../MatrixFactorizationTrainer.cs | 2 +- .../UnitTests/TestEntryPoints.cs | 2 -- .../TestPredictors.cs | 1 - .../MatrixFactorizationTests.cs | 23 ++++++++++--------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.ML.Recommender/MatrixFactorizationTrainer.cs b/src/Microsoft.ML.Recommender/MatrixFactorizationTrainer.cs index 430b33d8f3..00153171cf 100644 --- a/src/Microsoft.ML.Recommender/MatrixFactorizationTrainer.cs +++ b/src/Microsoft.ML.Recommender/MatrixFactorizationTrainer.cs @@ -513,7 +513,7 @@ private MatrixFactorizationModelParameters TrainCore(IChannel ch, RoleMappedData private SafeTrainingAndModelBuffer PrepareBuffer() { - return new SafeTrainingAndModelBuffer(_host, _fun, _k, _threads, Math.Max(20, 2 * _threads), + return new SafeTrainingAndModelBuffer(_host, _fun, _k, _threads, _threads == 1 ? 1 : Math.Max(20, 2 * _threads), _iter, _lambda, _eta, _alpha, _c, _doNmf, _quiet, copyData: false); } diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs index 30b6ba467d..f7dd2f4b58 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs @@ -2124,7 +2124,6 @@ public void EntryPointMulticlassPipelineEnsemble() [LessThanNetCore30OrNotNetCoreFact("netcoreapp3.0 output differs from Baseline")] //Skipping test temporarily. This test will be re-enabled once the cause of failures has been determined - [Trait("Category", "SkipInCI")] public void EntryPointPipelineEnsembleGetSummary() { var dataPath = GetDataPath("breast-cancer-withheader.txt"); @@ -6194,7 +6193,6 @@ public void TestOvaMacro() [Fact] //Skipping test temporarily. This test will be re-enabled once the cause of failures has been determined - [Trait("Category", "SkipInCI")] public void TestOvaMacroWithUncalibratedLearner() { var dataPath = GetDataPath(@"iris.txt"); diff --git a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs index 797831afc0..427124e617 100644 --- a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs +++ b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs @@ -189,7 +189,6 @@ public void MulticlassSdcaTest() [TestCategory("Logistic Regression")] [TestCategory("FastTree")] //Skipping test temporarily. This test will be re-enabled once the cause of failures has been determined - [Trait("Category", "SkipInCI")] public void MulticlassTreeFeaturizedLRTest() { RunMTAThread(() => diff --git a/test/Microsoft.ML.Tests/TrainerEstimators/MatrixFactorizationTests.cs b/test/Microsoft.ML.Tests/TrainerEstimators/MatrixFactorizationTests.cs index c39e1f7afa..439eb9af0a 100644 --- a/test/Microsoft.ML.Tests/TrainerEstimators/MatrixFactorizationTests.cs +++ b/test/Microsoft.ML.Tests/TrainerEstimators/MatrixFactorizationTests.cs @@ -55,7 +55,6 @@ public void MatrixFactorization_Estimator() [MatrixFactorizationFact] //Skipping test temporarily. This test will be re-enabled once the cause of failures has been determined - [Trait("Category", "SkipInCI")] public void MatrixFactorizationSimpleTrainAndPredict() { var mlContext = new MLContext(seed: 1); @@ -94,13 +93,13 @@ public void MatrixFactorizationSimpleTrainAndPredict() var rightMatrix = model.Model.RightFactorMatrix; Assert.Equal(leftMatrix.Count, model.Model.NumberOfRows * model.Model.ApproximationRank); Assert.Equal(rightMatrix.Count, model.Model.NumberOfColumns * model.Model.ApproximationRank); - // MF produce different matrices on different platforms, so at least test their content on windows. + // MF produce different matrices on different platforms, so check their content on Windows. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - Assert.Equal(0.33491, leftMatrix[0], 5); - Assert.Equal(0.571346991, leftMatrix[leftMatrix.Count - 1], 5); - Assert.Equal(0.2433036714792256, rightMatrix[0], 5); - Assert.Equal(0.381277978420258, rightMatrix[rightMatrix.Count - 1], 5); + Assert.Equal(0.301269173622131, leftMatrix[0], 5); + Assert.Equal(0.558746933937073, leftMatrix[leftMatrix.Count - 1], 5); + Assert.Equal(0.27028301358223, rightMatrix[0], 5); + Assert.Equal(0.390790820121765, rightMatrix[rightMatrix.Count - 1], 5); } // Read the test data set as an IDataView var testData = reader.Load(new MultiFileSource(GetDataPath(TestDatasets.trivialMatrixFactorization.testFilename))); @@ -124,12 +123,14 @@ public void MatrixFactorizationSimpleTrainAndPredict() var metrices = mlContext.Recommendation().Evaluate(prediction, labelColumnName: labelColumnName, scoreColumnName: scoreColumnName); // Determine if the selected metric is reasonable for different platforms - double tolerance = Math.Pow(10, -7); + // Windows tolerance is set at 1e-7, and Linux tolerance is set at 1e-5 + double windowsTolerance = Math.Pow(10, -7); + double linuxTolerance = Math.Pow(10, -5); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { // Linux case - var expectedUnixL2Error = 0.614457914950479; // Linux baseline - Assert.InRange(metrices.MeanSquaredError, expectedUnixL2Error - tolerance, expectedUnixL2Error + tolerance); + var expectedUnixL2Error = 0.612974867782832; // Linux baseline + Assert.InRange(metrices.MeanSquaredError, expectedUnixL2Error - linuxTolerance, expectedUnixL2Error + linuxTolerance); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { @@ -141,8 +142,8 @@ public void MatrixFactorizationSimpleTrainAndPredict() else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // Windows case - var expectedWindowsL2Error = 0.6098110249191965; // Windows baseline - Assert.InRange(metrices.MeanSquaredError, expectedWindowsL2Error - tolerance, expectedWindowsL2Error + tolerance); + var expectedWindowsL2Error = 0.622283290742721; // Windows baseline + Assert.InRange(metrices.MeanSquaredError, expectedWindowsL2Error - windowsTolerance, expectedWindowsL2Error + windowsTolerance); } var modelWithValidation = pipeline.Fit(data, testData);