Home > Enterprise >  sklearn: predict_proba method available in OneVsRestClassifier
sklearn: predict_proba method available in OneVsRestClassifier

Time:07-24

I am using sklearn's OneVsOneClassifier in an pipeline like so:

smt = SMOTE(random_state=42)
base_model = LogisticRegression()
pipeline = Pipeline([('sampler', smt), ('model', base_model)])

classifier = OneVsOneClassifier(estimator=pipeline)
classifier.fit(X_train, y_train)
# prediction
yhat = classifier.predict(X_test)

But then I cannot do:

yhat_prob = predict_proba(X_test)

AttributeError: 'OneVsOneClassifier' object has no attribute 'predict_proba'

scikit-learns OneVsRestClassifier does provide predict_proba method. I am suprised OneVsOneClassifier doesn't have this method.

How do I then get class probability estimates from my pipeline above?

CodePudding user response:

It's not clear how to use OvO to get probabilities, so it's not implemented. https://github.com/scikit-learn/scikit-learn/issues/6164

There is the decision_function method for a more nuanced version of predict.

  • Related