8000 [MRG+1] FIX Add missing mixins to ClassifierChain by jnothman · Pull Request #9473 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG+1] FIX Add missing mixins to ClassifierChain #9473

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

Merged
merged 2 commits into from
Aug 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sklearn/multioutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def score(self, X, y):
return np.mean(np.all(y == y_pred, axis=1))


class ClassifierChain(BaseEstimator):
class ClassifierChain(BaseEstimator, ClassifierMixin, MetaEstimatorMixin):
"""A multi-label model that arranges binary classifiers into a chain.

Each model makes a prediction in the order specified by the chain using
Expand Down
3 changes: 3 additions & 0 deletions sklearn/tests/test_multioutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from sklearn.multioutput import MultiOutputClassifier
from sklearn.multioutput import MultiOutputRegressor
from sklearn.svm import LinearSVC
from sklearn.base import ClassifierMixin
from sklearn.utils import shuffle


Expand Down Expand Up @@ -380,6 +381,8 @@ def test_classifier_chain_fit_and_predict_with_logistic_regression():
assert_equal([c.coef_.size for c in classifier_chain.estimators_],
list(range(X.shape[1], X.shape[1] + Y.shape[1])))

assert isinstance(classifier_chain, ClassifierMixin)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In light of #9475, you should probably use is_classifier

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in a test assertion. The point here is that it also ensures a default implementation is score

70D3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough



def test_classifier_chain_fit_and_predict_with_linear_svc():
# Fit classifier chain and verify predict performance using LinearSVC
Expand Down
0