Open
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
PriorPredictor
is successful OVA-AveragedPerceptron
is successfulOVA-PriorPredictor
fails
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
.