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

[MRG+1] Ovr/OVO classifier decision_function shape fixes #9100

Merged
merged 5 commits into from Jun 10, 2017

Conversation

@amueller
Copy link
Member

@amueller amueller commented Jun 10, 2017

OVR Classifier had a decision_function shape of (n_samples, 1) for binary classification, OVO classifier had (n_samples, 2) !
Fixed to conform to standard API.

@amueller amueller mentioned this pull request Jun 10, 2017
3 of 4 tasks
@amueller
Copy link
Member Author

@amueller amueller commented Jun 10, 2017

Found via #8022.

@@ -574,6 +576,8 @@ def predict(self, X):
Predicted multi-class targets.
"""
Y = self.decision_function(X)
if self.n_classes_ == 2:
return self.classes_[(Y > 0).astype(np.int)]

This comment has been minimized.

@vene

vene Jun 10, 2017
Member

This assumes that estimators_[0].decision_function correctly returns a vector. Are we relying on check_estimator to validate this, or should we check it here?

This comment has been minimized.

@amueller

amueller Jun 10, 2017
Author Member

no we should assume that base_estimator actually works. Otherwise everything in sklearn is broken ;)

This comment has been minimized.

@vene

vene Jun 10, 2017
Member

makes sense, lgtm then

@@ -251,6 +251,8 @@ def conduct_test(base_clf, test_predict_proba=False):
assert_equal(set(clf.classes_), classes)
y_pred = clf.predict(np.array([[0, 0, 4]]))[0]
assert_equal(set(y_pred), set("eggs"))
dec = clf.decision_function(X)
assert_equal(dec.shape, (5,))

This comment has been minimized.

@GaelVaroquaux

GaelVaroquaux Jun 10, 2017
Member

PEP8: missing space after comma

# first binary
ovo_clf.fit(iris.data, iris.target == 0)
decisions = ovo_clf.decision_function(iris.data)
assert_equal(decisions.shape, (n_samples,))

This comment has been minimized.

@GaelVaroquaux

GaelVaroquaux Jun 10, 2017
Member

PEP8 here too

This comment has been minimized.

@amueller

amueller Jun 10, 2017
Author Member

this is pep8....

@GaelVaroquaux
Copy link
Member

@GaelVaroquaux GaelVaroquaux commented Jun 10, 2017

LGTM. 👍

@GaelVaroquaux
Copy link
Member

@GaelVaroquaux GaelVaroquaux commented Jun 10, 2017

Aside from the PEP8 issues :)

@agramfort
Copy link
Member

@agramfort agramfort commented Jun 10, 2017

LGTM

+1 for merge when travis is happy

@agramfort agramfort changed the title [MRG] Ovr/OVO classifier decision_function shape fixes [MRG+1] Ovr/OVO classifier decision_function shape fixes Jun 10, 2017
@@ -251,6 +251,9 @@ def conduct_test(base_clf, test_predict_proba=False):
assert_equal(set(clf.classes_), classes)
y_pred = clf.predict(np.array([[0, 0, 4]]))[0]
assert_equal(set(y_pred), set("eggs"))
if hasattr(base_clf, 'decision_function'):
dec = clf.decision_function(X)
assert_equal(dec.shape, (5,))

This comment has been minimized.

@vene

vene Jun 10, 2017
Member

this breaks travis, line needs to be indented deeper

@amueller
Copy link
Member Author

@amueller amueller commented Jun 10, 2017

green! @vene?

@vene vene merged commit b43c791 into scikit-learn:master Jun 10, 2017
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sundrique added a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
* fix OVR classifier edgecase bugs

* add regression tests for OVO and OVR decision function shapes
dmohns added a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
* fix OVR classifier edgecase bugs

* add regression tests for OVO and OVR decision function shapes
dmohns added a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
* fix OVR classifier edgecase bugs

* add regression tests for OVO and OVR decision function shapes
NelleV added a commit to NelleV/scikit-learn that referenced this pull request Aug 11, 2017
* fix OVR classifier edgecase bugs

* add regression tests for OVO and OVR decision function shapes
paulha added a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
* fix OVR classifier edgecase bugs

* add regression tests for OVO and OVR decision function shapes
AishwaryaRK added a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
* fix OVR classifier edgecase bugs

* add regression tests for OVO and OVR decision function shapes
maskani-moh added a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
* fix OVR classifier edgecase bugs

* add regression tests for OVO and OVR decision function shapes
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
* fix OVR classifier edgecase bugs

* add regression tests for OVO and OVR decision function shapes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants