Skip to content

Probability is missing from the prediction Output schema of BinaryClassification.Trainers.AveragedPerceptron #3299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bsoman3 opened this issue Apr 11, 2019 · 3 comments

Comments

@bsoman3
Copy link

bsoman3 commented Apr 11, 2019

Issue

Using the Averaged Perceptron Binary Classifier in the Pipeline:

var pipeline =
//Other things in the pipeline
.Append(mlContext.BinaryClassification.Trainers.AveragedPerceptron(learningRate: lr, numIterations: 5));

//Fit Model steps
//Save Model steps
//Load Model steps

var predictions = loadedModel.Transform(data);
var metrics = mlContextTest.BinaryClassification.Evaluate(predictions);

Leads to the following error.

'Probability column 'Probability' not found
Parameter name: schema'

What Happened

Looking at the outputSchema of the predictions IDataView, the probability column is absent.

Expected Behavior

The Probability column should be available in the predictions IDataView based on reply by @zeahmed here- #376 (comment)

Looking at other binary classifiers like fast tree, that column is present in their output schema.

System information

  • Product: dotnet-ml-api
  • GitHub Login: @bsoman3
  • Microsoft Alias: bhsoman
  • OS version/distro:Windows 10 Enterprise
  • .NET Version (eg., dotnet --info): 4.6.1
@wschin
Copy link
Member

wschin commented Apr 11, 2019

AveragedPerceptron doesn't have probability output due to its math properties. To get probability, you need to add a calibrator. Please see

var calibratorEstimator = mlContext.BinaryClassification.Calibrators.Platt();
where it first trains AveragedPerceptron and then adds a calibrator.

@rogancarr
Copy link
Contributor

rogancarr commented Apr 12, 2019

You can also use your code as is, but evaluate with the EvaluateNonCalibrated evaluator.

mlContext.BinaryClassification.EvaluateNonCalibrated()

This is the preferred route if you don't actually need a probability or want probabilistic evaluation metrics.

@bsoman3
Copy link
Author

bsoman3 commented May 14, 2019

Makes sense! thanks for the input! This can be closed afaik

@bsoman3 bsoman3 closed this as completed May 14, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Mar 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants