8000 MultiOutputClassifier has predict_proba attribute for base classifiers without predict_proba · Issue #15488 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
MultiOutputClassifier has predict_proba attribute for base classifiers without predict_proba #15488
Closed
@rebekahkim

Description

@rebekahkim

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0