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 when even when base classifier does not have predict_proba.
MultiOutputClassifier
predict_proba
Improvement from PR #12222
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
hasattr(multi_target_linear, "predict_proba") returns False before fit and ValueError after fit.
hasattr(multi_target_linear, "predict_proba")
False
ValueError
hasattr(multi_target_linear, "predict_proba") returns True before and after fit.
True
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
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Description
MultiOutputClassifier
haspredict_proba
attribute when even when base classifier does not havepredict_proba
.Improvement from PR #12222
Steps/Code to Reproduce
Expected Results
hasattr(multi_target_linear, "predict_proba")
returnsFalse
before fit andValueError
after fit.Actual Results
hasattr(multi_target_linear, "predict_proba")
returnsTrue
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
The text was updated successfully, but these errors were encountered: