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

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

Comments

@rebekahkim
Copy link
Contributor

@rebekahkim rebekahkim commented Nov 2, 2019

Description

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 = iris.data
y1 = iris.target
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

multi_target_linear.fit(X, 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.

Versions

System:
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
Projects
None yet
1 participant
You can’t perform that action at this time.