Leon J
Leon J

Reputation: 41

Sklearn OneVsRestClassifier prediction probabilities do not amount to 1

So I am working on a multiclass problem with 6 outcome classes. I am using a OneVsRest classifier and trying to retrieve the prediction probabilties for every class using .predict_proba.

I was expecting the sum of the prediction probabilities of all classes for every observation to come out as one, however that is not the case.

predictor =  OneVsRestClassifier(xgb.XGBClassifier)
predictor.fit(X_train, y_train)
y_pred = predictor.predict_proba(X_test)
print(y_pred[1])

My output is: [0.11484083 0.02525082 0.02969465 0.58868223 0.09889702 0.03193117]

Can that be correct?

Upvotes: 0

Views: 577

Answers (1)

ThSorn
ThSorn

Reputation: 537

From the document of OneVsRestClassifier, this strategy consists in fitting one classifier per class. For each classifier, the class is fitted against all the other classes.. For example, if you want to classify dog, cat, and bird with OneVsRestClassifier, it will train 3 models.

  • first model will be trained to check if your data is dog or not.
  • second model will be trained to check if your data is bird or not.
  • third model will be trained to check if your data is cat or not.

Three models will be trained independently as a binary-class classification. So, the probability from three models do not sum up to 1.

Upvotes: 2

Related Questions