Skip to content

[MRG] fix ClassifierChain issue when a tuple is passed to order - #18124

Merged
thomasjpfan merged 18 commits into
scikit-learn:masterfrom
amy12xx:classifier_chain
Aug 17, 2020
Merged

thomasjpfan merged 18 commits into
scikit-learn:masterfrom
amy12xx:classifier_chain

Conversation

@amy12xx

@amy12xx amy12xx commented Aug 8, 2020

Copy link
Copy Markdown
Contributor

Fixes #17855, where if you passed a tuple to the order parameter to ClassifierChain, predict and predict_proba would throw an error.

Reference Issues/PRs

Closes #17890

@amy12xx amy12xx changed the title fix ClassifierChain issue when a tuple is passed to order [DRAFT] fix ClassifierChain issue when a tuple is passed to order Aug 8, 2020
@amy12xx amy12xx changed the title [DRAFT] fix ClassifierChain issue when a tuple is passed to order [MRG] fix ClassifierChain issue when a tuple is passed to order Aug 8, 2020

@rth rth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @amy12xx . LGTM aside for one comment below.

Please add an entry to the change log at doc/whats_new/v0.24.rst. Like the other entries there, please reference this pull request with :pr: and credit yourself (and other contributors if applicable) with :user:.

Comment thread sklearn/tests/test_multioutput.py Outdated

@rth rth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @amy12xx !

Comment thread doc/whats_new/v0.24.rst Outdated
Co-authored-by: Roman Yurchak <[email protected]>
Comment thread sklearn/tests/test_multioutput.py Outdated
Comment thread sklearn/tests/test_multioutput.py Outdated
Comment thread sklearn/multioutput.py Outdated
if self.order_ is None:
self.order_ = np.array(range(Y.shape[1]))
elif isinstance(self.order_, tuple):
self.order_ = np.array(self.order_)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we need to check that sorted(self.order_) == list(range(Y.shape[1])) as below

Comment thread sklearn/tests/test_multioutput.py Outdated
Comment on lines +623 to +625
else:
msg = 'invalid order'
assert_raise_message(ValueError, msg, chain.fit, X, y)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's define another test function to test for this assertion and use pytest.raises.

Comment thread sklearn/multioutput.py Outdated

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@thomasjpfan
thomasjpfan merged commit f656c37 into scikit-learn:master Aug 17, 2020
jayzed82 pushed a commit to jayzed82/scikit-learn that referenced this pull request Oct 22, 2020
…it-learn#18124)

* fix error tuple passed to order

* fix linting

* Update sklearn/tests/test_multioutput.py

Co-authored-by: Roman Yurchak <[email protected]>

* updated test and whatsnew

* doc fix

* Update doc/whats_new/v0.24.rst

Co-authored-by: Roman Yurchak <[email protected]>

* Update sklearn/tests/test_multioutput.py

Co-authored-by: Thomas J. Fan <[email protected]>

* Update sklearn/tests/test_multioutput.py

Co-authored-by: Thomas J. Fan <[email protected]>

* code review fix

* code review fix

* added test

* code review fix

* Update sklearn/multioutput.py

Co-authored-by: Joel Nothman <[email protected]>

Co-authored-by: Roman Yurchak <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Joel Nothman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClassifierChain -- predict and predict_proba throw error when order is a tuple

4 participants