Repository navigation
Open
Labels
area-TrainersMachine learning trainers and training APIsbugSomething isn't workinggreendevelopmentyellowmaintenance only
Description
When placed in a One-vs-All (OVA), PriorPredictor throws a "Nullable object must have a value" error.
Error:
Unhandled exception. System.InvalidOperationException: Nullable object must have a value.
at System.Nullable`1.get_Value()
at Microsoft.ML.Data.SchemaBindablePredictorWrapperBase.SingleValueRowMapper.GetInputColumnRoles()+MoveNext()
at Microsoft.ML.Data.RoleMappedSchema.MapFromNames(DataViewSchema schema, IEnumerable`1 roles, Boolean opt)
at Microsoft.ML.Data.RoleMappedSchema..ctor(DataViewSchema schema, IEnumerable`1 roles, Boolean opt)
at Microsoft.ML.Data.PredictedLabelScorerBase.BindingsImpl.ApplyToSchema(DataViewSchema input, ISchemaBindableMapper bindable, IHostEnvironment env)
at Microsoft.ML.Data.PredictedLabelScorerBase..ctor(IHostEnvironment env, PredictedLabelScorerBase transform, IDataView newSource, String registrationName)
at Microsoft.ML.Data.MulticlassClassificationScorer..ctor(IHostEnvironment env, MulticlassClassificationScorer transform, IDataView newSource)
at Microsoft.ML.Data.MulticlassClassificationScorer.ApplyToDataCore(IHostEnvironment env, IDataView newSource)
at Microsoft.ML.Data.RowToRowScorerBase.ApplyToData(IHostEnvironment env, IDataView newSource)
at Microsoft.ML.Data.PredictionTransformerBase`1.Transform(IDataView input)
at Microsoft.ML.Data.EstimatorChain`1.Fit(IDataView input)
at Program.Main()
PriorPredictor does work properly when not in an OVA (aka, used as a normal binary trainer).
Repro:
See fiddle: https://dotnetfiddle.net/bs5hiw
Fiddle demonstrates:
- Binary
PriorPredictoris successful OVA-AveragedPerceptronis successfulOVA-PriorPredictorfails
Relevant code:
var baselineMulticlassPipeline = mlContext.Transforms.Conversion.MapValueToKey("Label", "Label")
.Append(mlContext.MulticlassClassification.Trainers.OneVersusAll(mlContext.BinaryClassification.Trainers.Prior(labelColumnName: "Label"), labelColumnName: "Label"));
var multiclassModel = baselineMulticlassPipeline.Fit(split.TrainSet);Cause:
PriorPredictor differs from other trainers in part as it doesn't take in a Features column (and only looks at the Label column). My first guess would be when wrapping the One-vs-All in an Estimators API, we missed the part that the Features column won't exist for the PriorPredictor.
Metadata
Metadata
Assignees
Labels
area-TrainersMachine learning trainers and training APIsbugSomething isn't workinggreendevelopmentyellowmaintenance only
Activity
justinormont commentedon Jan 4, 2021
Why OVA-PriorPredictor:
The
PriorPredictoris good at establishing baseline metrics from which you can measure improvement. The trainer always guesses the largest class in your dataset. ThePriorPredictoris trained on your training dataset and evaluated on your validation/test dataset(s) (or cross-validation), giving you a measure of how well a NOOP trainer performs, including factors like distribution drift and sampling/splitting variability.Docs: https://docs.microsoft.com/en-us/dotnet/api/microsoft.ml.standardtrainerscatalog.prior
Nit bug -- "models" is misspelt here:
machinelearning/src/Microsoft.ML.StandardTrainers/StandardTrainersCatalog.cs
Lines 857 to 858 in 5dbfd8a
svick commentedon Nov 27, 2026
Triage: Keeping this open as a bug. Prior intentionally does not use a feature column, but OVA's multiclass scoring path assumes one exists and throws when binding the model.
Adding a dummy Features column does not work around this, because the Prior transformer still reports no feature-column name.
We should make this scoring path handle featureless predictors and add regression coverage for OneVersusAll(Prior()), while preserving standalone binary Prior behavior.
Note
This comment was written by GitHub Copilot.