dotnet/machinelearning · error · NotImplementedException
{metric} is not supported!
Error message
{metric} is not supported! What it means
The RegressionTrialRunner's GetMetric maps RegressionMetric enum values to metric fields; only RootMeanSquaredError, RSquared, MeanSquaredError, and MeanAbsoluteError are mapped. Any other RegressionMetric value reaches the default arm and throws NotImplementedException.
Source
Thrown at src/Microsoft.ML.AutoML/API/RegressionExperiment.cs:477
throw;
}
}
public void Dispose()
{
_context.CancelExecution();
_context = null;
}
private double GetMetric(RegressionMetric metric, RegressionMetrics metrics)
{
return metric switch
{
RegressionMetric.RootMeanSquaredError => metrics.RootMeanSquaredError,
RegressionMetric.RSquared => metrics.RSquared,
RegressionMetric.MeanSquaredError => metrics.MeanSquaredError,
RegressionMetric.MeanAbsoluteError => metrics.MeanAbsoluteError,
_ => throw new NotImplementedException($"{metric} is not supported!"),
};
}
}
}
View on GitHub (pinned to 7b76e69cf9)
Solutions
- Set the experiment's optimizer metric to RootMeanSquaredError, RSquared, MeanSquaredError, or MeanAbsoluteError.
- Validate the configured metric against the supported set before starting the sweep.
- Extend the switch with an arm for the required metric and upstream the change.
Example fix
// before var exp = ctx.Auto().CreateRegressionExperiment(data); exp.SetMetric(RegressionMetric.PoissonLoss); // throws in runner // after exp.SetMetric(RegressionMetric.RootMeanSquaredError);
Defensive patterns
Strategy: validation
Validate before calling
private static readonly RegressionMetric[] SupportedMetrics =
{
RegressionMetric.RootMeanSquaredError,
RegressionMetric.RSquared,
RegressionMetric.MeanSquaredError,
RegressionMetric.MeanAbsoluteError
};
// before running:
if (!SupportedMetrics.Contains(metric)) throw new ArgumentException($"Metric {metric} not supported by the regression runner"); Type guard
bool IsSupported(RegressionMetric m) => m is RegressionMetric.RootMeanSquaredError or RegressionMetric.RSquared or RegressionMetric.MeanSquaredError or RegressionMetric.MeanAbsoluteError;
Try / catch
try { exp.SetMetric(metric); }
catch (NotImplementedException) { exp.SetMetric(RegressionMetric.RootMeanSquaredError); // safe default
} Prevention
- Pick optimizer metrics only from the four documented regression metrics
- Validate metric config before experiment construction
- Prefer RootMeanSquaredError as the safe default for regression sweeps
When it happens
Trigger: Requesting a RegressionMetric not in the four supported arms (e.g. RootMeanSquaredErrorTransformed, PoissonLoss, or LogLoss) when the runner computes the score of a trial.
Common situations: Choosing an optimizer metric that exists on the RegressionMetric enum but is not wired into the AutoML runner; enum members added in newer ML.NET versions; configs specifying a loss metric intended for a different trainer.
Related errors
- {metric} is not supported!
- {metric} is not supported!
- joinAlgorithm
- The runner metric manager is of type {_metricManager.GetType
- {fieldType.Name}
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/5e6ef8635147c855.
Report an issue: GitHub.