Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxModels exit criteria for AutoML unit test #5471

Merged
merged 2 commits into from
Nov 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions test/Microsoft.ML.AutoML.Tests/AutoFitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public void AutoFitRegressionTest(string culture)
// the sweeper encounters problems when parsing some strings.
// So testing in another culture is necessary.
// Furthermore, these issues might only occur after ~70
// iterations, so more experiment time is needed for this to
// occur.
uint experimentTime = (uint) (culture == "en-US" ? 0 : 180);
// iterations, so setting the internal maxModels parameter.
int maxModels = culture == "en-US" ? 1 : 75;

var experimentSettings = new RegressionExperimentSettings { MaxModels = maxModels };

var experimentSettings = new RegressionExperimentSettings { MaxExperimentTimeInSeconds = experimentTime};
if (!Environment.Is64BitProcess)
{
// LightGBM isn't available on x86 machines
Expand All @@ -144,27 +144,10 @@ public void AutoFitRegressionTest(string culture)
.Execute(trainData, validationData,
new ColumnInformation() { LabelColumnName = DatasetUtil.MlNetGeneratedRegressionLabel });

Assert.True(result.RunDetails.Max(i => i?.ValidationMetrics?.RSquared) > 0.9);
Assert.True(result.RunDetails.Max(i => i?.ValidationMetrics?.RSquared) > 0.99);

// Ensure experimentTime allows enough iterations to fully test the internationalization code
// If the below assertion fails, increase the experiment time so the number of iterations is met
Assert.True(culture == "en-US" || result.RunDetails.Count() >= 75, $"RunDetails.Count() = {result.RunDetails.Count()}, below 75");
}
catch (AggregateException ae)
{
// During CI unit testing, the host machines can run slower than normal, which
// can increase the run time of unit tests and throw OperationCanceledExceptions
// from multiple threads in the form of a single AggregateException.
foreach (var ex in ae.Flatten().InnerExceptions)
{
var ignoredExceptions = new List<Exception>();
if (ex is OperationCanceledException)
continue;
else
ignoredExceptions.Add(ex);
if (ignoredExceptions.Count > 0)
throw new AggregateException(ignoredExceptions);
}
// Test the internal maxModels parameter
Assert.True(culture == "en-US" || result.RunDetails.Count() == 75, $"RunDetails.Count() = {result.RunDetails.Count()}, is not 75");
}
finally
{
Expand Down