dotnet/machinelearning · error · ArgumentException
The runner metric manager is of type {_metricManager.GetType
Error message
The runner metric manager is of type {_metricManager.GetType()} which expected to be of type {typeof(ITrainValidateDatasetManager)} or {typeof(ICrossValidateDatasetManager)} What it means
RegressionExperiment.RunAsync's evaluation loop dispatches on the type of _metricManager and only handles ITrainValidateDatasetManager and ICrossValidateDatasetManager. When the manager is another type, neither branch produces a TrialResult and control reaches the trailing throw of ArgumentException, indicating a misconfigured runner.
Source
Thrown at src/Microsoft.ML.AutoML/API/RegressionExperiment.cs:450
var loss = metricManager.IsMaximize ? -metric : metric;
stopWatch.Stop();
return Task.FromResult(new TrialResult<RegressionMetrics>()
{
Loss = loss,
Metric = metric,
Metrics = metrics,
Model = model,
TrialSettings = settings,
DurationInMilliseconds = stopWatch.ElapsedMilliseconds,
Pipeline = refitPipeline,
} as TrialResult);
}
}
throw new ArgumentException($"The runner metric manager is of type {_metricManager.GetType()} which expected to be of type {typeof(ITrainValidateDatasetManager)} or {typeof(ICrossValidateDatasetManager)}");
}
}
catch (Exception ex) when (ct.IsCancellationRequested)
{
throw new OperationCanceledException(ex.Message, ex.InnerException);
}
catch (Exception)
{
throw;
}
}
public void Dispose()
{
_context.CancelExecution();
_context = null;
}
View on GitHub (pinned to 7b76e69cf9)
Solutions
- Construct the experiment through the standard builders so a TrainTestSplit (ITrainValidateDatasetManager) or CrossValidation (ICrossValidateDatasetManager) manager is used.
- Make custom dataset managers implement one of the two expected interfaces.
- Validate the manager type at experiment setup and throw early with a descriptive message.
- Align all Microsoft.ML.AutoML package references to the same version.
Example fix
// before experiment.SetDataset(new MyDatasetManager(data)); // unsupported type await experiment.RunAsync(ct); // after experiment.SetDataset(new CrossValidationDatasetManager(data, numFolds: 5)); await experiment.RunAsync(ct);
Defensive patterns
Strategy: type-guard
Validate before calling
// before RunAsync:
if (_metricManager is not ITrainValidateDatasetManager and not ICrossValidateDatasetManager)
throw new InvalidOperationException("Use TrainTestSplit or CrossValidation dataset manager"); Type guard
bool IsValidManager(object m) => m is ITrainValidateDatasetManager or ICrossValidateDatasetManager;
Try / catch
try { var best = await experiment.RunAsync(ct); }
catch (ArgumentException ex) when (ex.Message.Contains("metric manager")) { // rebuild experiment with standard dataset manager
throw new InvalidOperationException("Regression experiment dataset manager misconfigured", ex); } Prevention
- Build regression experiments through mlContext.Auto().CreateRegressionExperiment/StandardPipelines
- Avoid custom IDatasetManager implementations unless they implement the expected interfaces
- Add a construction-time assertion for the manager type
When it happens
Trigger: Running a regression AutoML experiment whose metric/dataset manager object is neither ITrainValidateDatasetManager nor ICrossValidateDatasetManager (custom implementation or wrong object injected), so both switch branches are skipped and the terminal ArgumentException is hit.
Common situations: Hand-rolled AutoML runners; dependency-injection misconfiguration supplying a custom IDatasetManager; package version mismatch where runner interfaces were refactored.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- The runner metric manager is of type {_metricManager.GetType
- result must be of type {typeof(TrialResult<TMetrics>)}
- Strings.BadColumnCast (formatted with column.DataType, typeo
- Strings.BadColumnCast (formatted with column.DataType, typeo
- Strings.BadColumnCast (formatted with column.DataType, typeo
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/2d8d0f74ec86c34e.
Report an issue: GitHub.