dotnet/machinelearning · error · NotSupportedException
Unsupported task type
Error message
Unsupported task type: {task} What it means
GetAllowedLabelTypes maps an AutoML TaskKind to the label DataViewTypes that task supports. If the task falls through the switch, NotSupportedException 'Unsupported task type' is thrown — meaning the task value isn't one of binary/multiclass/regression/recommendation/ranking.
Solutions
- Use a supported task: binary/multiclass classification, regression, recommendation, or ranking.
- Update the Microsoft.ML.AutoML package to a version matching the task enum value you specify.
- Log the actual task value to confirm what is being passed; fix the config/code mapping.
Example fix
// before var settings = new MulticlassExperimentSettings(...); // task resolved to unknown kind on older package // after dotnet add package Microsoft.ML.AutoML --version <latest> var experiment = mlContext.Auto().CreateMulticlassExperiment(settings);
Defensive patterns
Strategy: type-guard
Validate before calling
var supported = new[] { "binary-classification", "multiclass-classification", "regression", "recommendation", "ranking" };
if (!supported.Contains(taskName)) throw new InvalidOperationException($"task {taskName} not supported by this ML.NET version"); Type guard
bool IsKnownTaskKind(TaskKind kind) =>
kind is TaskKind.BinaryClassification or TaskKind.MulticlassClassification or TaskKind.Regression or TaskKind.Recommendation or TaskKind.Ranking; Try / catch
try { result = experiment.Execute(trainData, settings); }
catch (NotSupportedException ex) when (ex.Message.StartsWith("Unsupported task type")) { /* fall back to a supported task or upgrade package */ } Prevention
- Pin Microsoft.ML.AutoML versions across services
- Never cast raw ints to TaskKind
- Validate config-driven task names against the supported list
When it happens
Trigger: Passing a TaskName/Task to AutoML APIs whose mapped TaskKind isn't handled (future/unknown enum value, default case), typically via ValidateColumnInformation during Execute on a newer enum value used with an older ML.NET build.
Common situations: Assembly/version mismatch where a new task enum was serialized or specified but the loaded Microsoft.ML.AutoML doesn't recognize it; typo casting an int to TaskKind; configuration-driven task names mapped incorrectly.
Related errors
- column must be of data type
- Duplicate column name
- File at path ' ' cannot be empty
- File ' ' does not exist
- If provided, must be the same as for Ranking Experiments
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/5f53e3e97a0ccba1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.ML.AutoML/Utils/UserInputValidationUtil.cs:323
}
private static IEnumerable<DataViewType> GetAllowedLabelTypes(TaskKind task)
{
switch (task)
{
case TaskKind.BinaryClassification:
return new DataViewType[] { BooleanDataViewType.Instance };
// Multiclass label types are flexible, as we convert the label to a key type
// (if input label is not already a key) before invoking the trainer.
case TaskKind.MulticlassClassification:
return null;
case TaskKind.Regression:
case TaskKind.Recommendation:
return new DataViewType[] { NumberDataViewType.Single };
case TaskKind.Ranking:
return new DataViewType[] { NumberDataViewType.Single };
default:
throw new NotSupportedException($"Unsupported task type: {task}");
}
}
}
}
View on GitHub (pinned to 7b76e69cf9)