Skip to content
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

MultiOutputClassifier has predict_proba attribute for base classifiers without predict_proba #15488

rebekahkim opened this issue Nov 2, 2019 · 0 comments · Fixed by #15490


Copy link

@rebekahkim rebekahkim commented Nov 2, 2019


MultiOutputClassifier has predict_proba attribute when even when base classifier does not have predict_proba.

Improvement from PR #12222

Steps/Code to Reproduce

from sklearn.linear_model import SGDClassifier
from sklearn.multioutput import MultiOutputClassifier

from sklearn import datasets
from sklearn.utils import shuffle
import numpy as np

iris = datasets.load_iris()
X =
y1 =
y2 = shuffle(y1, random_state=1)
y3 = shuffle(y1, random_state=2)
y = np.column_stack((y1, y2, y3))

sgd_linear_clf = SGDClassifier(random_state=1, max_iter=5)
multi_target_linear = MultiOutputClassifier(sgd_linear_clf)
hasattr(multi_target_linear, "predict_proba") # returns True, y)
hasattr(multi_target_linear, "predict_proba") # returns True

multi_target_linear.predict_proba(X) # raises ValueError

Expected Results

hasattr(multi_target_linear, "predict_proba") returns False before fit and ValueError after fit.

Actual Results

hasattr(multi_target_linear, "predict_proba") returns True before and after fit.


python: 3.7.5 (default, Oct 25 2019, 10:52:18) [Clang 4.0.1 (tags/RELEASE_401/final)]
executable: /usr/local/anaconda3/envs/sklearndev/bin/python3
machine: Darwin-19.0.0-x86_64-i386-64bit

Python deps:
pip: 19.3.1
setuptools: 41.6.0.post20191030
sklearn: 0.22.dev0
numpy: 1.17.2
scipy: 1.3.1
Cython: 0.29.13
pandas: None
matplotlib: 3.1.1
joblib: 0.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging a pull request may close this issue.

1 participant