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

The AutoML experiment runner's _metricManager must be an ITrainValidateDatasetManager or ICrossValidateDatasetManager for BinaryClassification trials; if it is any other type, Run throws ArgumentException because the metric/dataset management contract is unfulfillable. This is an internal invariant failure of the AutoML framework.

Source

Thrown at src/Microsoft.ML.AutoML/API/BinaryClassificationExperiment.cs:445

                    var loss = metricManager.IsMaximize ? -metric : metric;

                    stopWatch.Stop();


                    return new TrialResult<BinaryClassificationMetrics>()
                    {
                        Loss = loss,
                        Metric = metric,
                        Model = model,
                        TrialSettings = settings,
                        DurationInMilliseconds = stopWatch.ElapsedMilliseconds,
                        Metrics = metrics,
                        Pipeline = refitPipeline,
                    };
                }
            }

            throw new ArgumentException($"The runner metric manager is of type {_metricManager.GetType()} which expected to be of type {typeof(ITrainValidateDatasetManager)} or {typeof(ICrossValidateDatasetManager)}");
        }

        public Task<TrialResult> RunAsync(TrialSettings settings, CancellationToken ct)
        {
            try
            {
                using (var ctRegistration = ct.Register(() =>
                {
                    _context?.CancelExecution();
                }))
                {
                    return Task.FromResult(Run(settings));
                }
            }
            catch (Exception ex) when (ct.IsCancellationRequested)
            {
                throw new OperationCanceledException(ex.Message, ex.InnerException);
            }

View on GitHub (pinned to 7b76e69cf9)

Solutions

  1. Use a supported Microsoft.ML.AutoML version and avoid mixing AutoML assemblies
  2. Ensure custom experiment/runners set _metricManager to ITrainValidateDatasetManager or ICrossValidateDatasetManager
  3. Report/pin consistent package versions across Microsoft.ML.AutoML and dependents

Example fix

// before: custom runner with wrong manager
_metricManager = new MyCustomDatasetManager();
// after
_metricManager = new TrainValidateDatasetManager(...); // or CrossValidationDatasetManager
Defensive patterns

Strategy: try-catch

Validate before calling

// pin and verify AutoML package versions at build time
dotnet list package --include-transitive | grep Microsoft.ML.AutoML

Type guard

null

Try / catch

try { var r = experiment.Run(trainData, null); } catch (ArgumentException ex) when (ex.Message.Contains("runner metric manager")) { // fix component wiring / package versions, then rerun
    throw; }

Prevention

When it happens

Trigger: TrialSettings/Tuner configuration producing a metric manager of an unexpected type — e.g. custom experiment extensions or mismatched AutoML component versions where a different IDatasetManager implementation is injected.

Common situations: Mixing Microsoft.ML.AutoML package versions; subclassing/extending experiments and wiring a custom runner whose _metricManager isn't one of the two supported managers.

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


AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11). Data as JSON: /api/errors/810642a2acfb8524. Report an issue: GitHub.