Skip to content

OVA-PriorPredictor fails #5575

Open
Open
@justinormont

Description

@justinormont

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 successful
  • OVA-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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclassificationBugs related classification tasks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions