Skip to content

Commit

Permalink
Changed code path to ensure threshold is changed (#4104)
Browse files Browse the repository at this point in the history
* Fixed build errors resulting from upgrade to VS2019 compilers

* Added additional message describing the previous fix

* Changed function call to test with changed threshold
  • Loading branch information
harishsk authored Sep 11, 2019
1 parent b11f3f0 commit 64b0e5e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/Microsoft.ML.Tests/AnomalyDetectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static void RandomizedPcaChangeThreshold()
var trainer1 = mlContext.AnomalyDetection.Trainers.RandomizedPca(featureColumnName: nameof(DataPoint.Features), rank: 1, ensureZeroMean: false);

// Test the first detector.
ExecutePipelineWithGivenRandomizedPcaTrainer(mlContext, trainer1);
ExecuteRandomizedPcaTrainerChangeThreshold(mlContext, trainer1);

// Object required in the creation of another detector.
var options = new Trainers.RandomizedPcaTrainer.Options()
Expand All @@ -106,7 +106,7 @@ public static void RandomizedPcaChangeThreshold()
var trainer2 = mlContext.AnomalyDetection.Trainers.RandomizedPca(options);

// Test the second detector.
ExecutePipelineWithGivenRandomizedPcaTrainer(mlContext, trainer2);
ExecuteRandomizedPcaTrainerChangeThreshold(mlContext, trainer2);
}

/// <summary>
Expand Down Expand Up @@ -204,22 +204,22 @@ private static void ExecuteRandomizedPcaTrainerChangeThreshold(MLContext mlConte
// Read ML.NET predictions into IEnumerable<Result>.
var results = mlContext.Data.CreateEnumerable<Result>(transformed, reuseRowObject: false).ToList();

// Inlier should be predicted as false.
Assert.False(results[0].PredictedLabel);
Assert.InRange(results[0].Score, 0, 0.3);
// Outlier should be predicted as true.
Assert.True(results[0].PredictedLabel);
Assert.InRange(results[0].Score, 0.3, 1);
// Inlier should be predicted as false.
Assert.False(results[1].PredictedLabel);
Assert.InRange(results[1].Score, 0, 0.3);
// Inlier should be predicted as false.
Assert.False(results[2].PredictedLabel);
Assert.InRange(results[2].Score, 0, 0.3);
// Inlier should be predicted as false.
Assert.False(results[3].PredictedLabel);
Assert.InRange(results[3].Score, 0, 0.3);

// Outlier should be predicted as true.
Assert.True(results[4].PredictedLabel);
Assert.InRange(results[4].Score, 0.3, 1);
Assert.True(results[3].PredictedLabel);
Assert.InRange(results[3].Score, 0.3, 1);

// Inlier should be predicted as false.
Assert.False(results[4].PredictedLabel);
Assert.InRange(results[4].Score, 0, 0.3);

// Inlier should be predicted as false.
Assert.False(results[5].PredictedLabel);
Expand Down

0 comments on commit 64b0e5e

Please sign in to comment.