dotnet / dotnet/machinelearning

AutoML 2.0: regression throws The given key 'e4' was not present in the dictionary.

Open
#6,755 8 comments 0 reactions 1 assignee Claimed by @LittleLittleCloud View on GitHub
area-AutoML
Dominant language
C#
Stars
9.4k
Forks
2k
Avg merge
2d 20h
Merged PRs (30d)
11

Description

**System Information (please complete the following information):**
- OS & Version: windows 11
- ML.NET Version: ML.NET nightly 4th July 2023
- .NET Version: .NET 7.0

**Describe the bug**

When running regression experiment I got this error. It seems to appear at "random" experiment. I have got it on 2nd, 4th and now not yet for 21 trials.

```
System.Collections.Generic.KeyNotFoundException: The given key 'e4' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Microsoft.ML.SearchSpace.SearchSpace.MappingToFeatureSpace(Parameter parameter)
at Microsoft.ML.SearchSpace.SearchSpace.MappingToFeatureSpace(Parameter parameter)
at Microsoft.ML.AutoML.CsvTrialResultManager.Save()
at Microsoft.ML.AutoML.AutoMLExperiment.RunAsync(CancellationToken ct)
at Kwork.MLTrainer2023Regression.Program.TrainRegression(List`1 trainingDataFiles, String LabelColumn, String saveTo, UInt32 trainingTimeSeconds) in C:\git\Kwork.MLTrainer2023\Kwork.MLTrainer2023Regression\Program.cs:line 422
at Kwork.MLTrainer2023Regression.Program.Main(String[] args) in C:\git\Kwork.MLTrainer2023\Kwork.MLTrainer2023Regression\Program.cs:line 190
The given key 'e4' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Microsoft.ML.SearchSpace.SearchSpace.MappingToFeatureSpace(Parameter parameter)
at Microsoft.ML.SearchSpace.SearchSpace.MappingToFeatureSpace(Parameter parameter)
at Microsoft.ML.AutoML.CsvTrialResultManager.Save()
at Microsoft.ML.AutoML.AutoMLExperiment.RunAsync(CancellationToken ct)
at Kwork.MLTrainer2023Regression.Program.TrainRegression(List`1 trainingDataFiles, String LabelColumn, String saveTo, UInt32 trainingTimeSeconds) in C:\git\Kwork.MLTrainer2023\Kwork.MLTrainer2023Regression\Program.cs:line 422
at Kwork.MLTrainer2023Regression.Program.Main(String[] args) in C:\git\Kwork.MLTrainer2023\Kwork.MLTrainer2023Regression\

```

my code:
```
pipeline = ctx.Transforms
.SelectColumns(columnsToKeep) // Keep only the specified columns
.Append(ctx.Auto().Featurizer(data, columnInformation: columnInference.ColumnInformation))
.Append(ctx.Auto().Regression(labelColumnName: columnInference.ColumnInformation.LabelColumnName,
useFastForest: false, useSdca: false, useLbfgsPoissonRegression: false, useLgbm: false,
useFastTree: true
)); //disable slow FastForest, run LightGBM on GPU machine
```

```
AutoMLExperiment.AutoMLExperimentSettings settings = new AutoMLExperiment.AutoMLExperimentSettings();
AutoMLExperiment experiment = ctx.Auto().CreateExperiment();

// Configure experiment
experiment
.SetPipeline(pipeline)
.SetRegressionMetric(RegressionMetric.RootMeanSquaredError, labelColumn: columnInference.ColumnInformation.LabelColumnName)
.SetTrainingTimeInSeconds(trainingTimeSeconds)
.SetDataset(data, fold: NumFolds, samplingKeyColumnName: SamplingKeyColumn)
.SetEciCostFrugalTuner();

var monitor = new AutoMLMonitor(pipeline);
experiment.SetMonitor(monitor);

var cts = new CancellationTokenSource();
Console.WriteLine("Start experiment");
TrialResult experimentResults = await experiment.RunAsync(cts.Token);
```


Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.