The Wayback Machine - https://web.archive.org/web/20210824103245/https://github.com/scikit-learn/scikit-learn/pull/18124
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] fix ClassifierChain issue when a tuple is passed to order #18124

Merged
merged 18 commits into from Aug 17, 2020
Merged

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

merged 18 commits into from Aug 17, 2020

Conversation

@amy12xx
Copy link
Contributor

@amy12xx amy12xx commented Aug 8, 2020

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
Copy link
Member

@rth rth left a comment

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:.

sklearn/tests/test_multioutput.py Outdated Show resolved Hide resolved
@rth
rth approved these changes Aug 15, 2020
Copy link
Member

@rth rth left a comment

Thank you @amy12xx !

doc/whats_new/v0.24.rst Outdated Show resolved Hide resolved
Co-authored-by: Roman Yurchak <[email protected]>
sklearn/tests/test_multioutput.py Outdated Show resolved Hide resolved
sklearn/tests/test_multioutput.py Outdated Show resolved Hide resolved
@@ -455,6 +455,8 @@ def fit(self, X, Y, **fit_params):
self.order_ = self.order
if self.order_ is None:
self.order_ = np.array(range(Y.shape[1]))
elif isinstance(self.order_, tuple):
self.order_ = np.array(self.order_)

This comment has been minimized.

@jnothman

jnothman Aug 16, 2020
Member

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

else:
msg = 'invalid order'
assert_raise_message(ValueError, msg, chain.fit, X, y)
Comment on lines 623 to 625

This comment has been minimized.

@thomasjpfan

thomasjpfan Aug 16, 2020
Member

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

sklearn/multioutput.py Outdated Show resolved Hide resolved
Copy link
Member

@thomasjpfan thomasjpfan left a comment

LGTM

@thomasjpfan thomasjpfan merged commit f656c37 into scikit-learn:master Aug 17, 2020
19 checks passed
19 checks passed
@lgtm-com
LGTM analysis: C/C++ No code changes detected
Details
@lgtm-com
LGTM analysis: JavaScript No code changes detected
Details
@lgtm-com
LGTM analysis: Python No new or fixed alerts
Details
ci/circleci: deploy Your tests passed on CircleCI!
Details
ci/circleci: doc Your tests passed on CircleCI!
Details
@circleci-artifacts-redirector
ci/circleci: doc artifact Link to 0/doc/_changed.html
Details
ci/circleci: doc-min-dependencies Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
@azure-pipelines
scikit-learn.scikit-learn Build #20200817.3 succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (Linting) Linting succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (Linux py36_conda_openblas) Linux py36_conda_openblas succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (Linux py36_ubuntu_atlas) Linux py36_ubuntu_atlas succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (Linux pylatest_pip_openblas_pandas) Linux pylatest_pip_openblas_pandas succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (Linux32 py36_ubuntu_atlas_32bit) Linux32 py36_ubuntu_atlas_32bit succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (Linux_Runs pylatest_conda_mkl) Linux_Runs pylatest_conda_mkl succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (Windows py36_pip_openblas_32bit) Windows py36_pip_openblas_32bit succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (Windows py37_conda_mkl) Windows py37_conda_mkl succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (macOS pylatest_conda_mkl) macOS pylatest_conda_mkl succeeded
Details
@azure-pipelines
scikit-learn.scikit-learn (macOS pylatest_conda_mkl_no_openmp) macOS pylatest_conda_mkl_no_openmp succeeded
Details
jayzed82 added 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
Linked issues

Successfully merging this pull request may close these issues.

4 participants