Skip to content

Commit

Permalink
avoid empty dataset (#6756)
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleLittleCloud authored Jul 6, 2023
1 parent 26c2446 commit 36f87d1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Microsoft.ML.AutoML/AutoMLExperiment/IDatasetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,15 @@ public IDataView LoadTrainDataset(MLContext context, TrialSettings? settings)
var subSampleRatio = parameter.ContainsKey(_subSamplingKey) ? parameter[_subSamplingKey].AsType<double>() : 1;
if (subSampleRatio < 1.0)
{
var subSampledTrainDataset = context.Data.TakeRows(_trainDataset, (long)(subSampleRatio * _rowCount));
var count = (long)(subSampleRatio * _rowCount);
if (count <= 10)
{
// fix issue https://github.com/dotnet/machinelearning-modelbuilder/issues/2734
// take at least 10 rows to avoid empty dataset
count = 10;
}

var subSampledTrainDataset = context.Data.TakeRows(_trainDataset, count);
return subSampledTrainDataset;
}
}
Expand Down

0 comments on commit 36f87d1

Please sign in to comment.