[MRG] fix ClassifierChain issue when a tuple is passed to order #18124
+37
−1
Conversation
Co-authored-by: Roman Yurchak <[email protected]>
…learn into classifier_chain
Co-authored-by: Roman Yurchak <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>
Co-authored-by: Thomas J. Fan <[email protected]>
…learn into classifier_chain
sklearn/multioutput.py
Outdated
@@ -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_) |
jnothman
Aug 16, 2020
Member
we need to check that sorted(self.order_) == list(range(Y.shape[1]))
as below
we need to check that sorted(self.order_) == list(range(Y.shape[1]))
as below
sklearn/tests/test_multioutput.py
Outdated
else: | ||
msg = 'invalid order' | ||
assert_raise_message(ValueError, msg, chain.fit, X, y) |
Comment on lines
623
to
625
thomasjpfan
Aug 16, 2020
Member
Let's define another test function to test for this assertion and use pytest.raises
.
Let's define another test function to test for this assertion and use pytest.raises
.
…into classifier_chain
Co-authored-by: Joel Nothman <[email protected]>
LGTM |
f656c37
into
scikit-learn:master
19 checks passed
19 checks passed
scikit-learn.scikit-learn (Linux pylatest_pip_openblas_pandas)
Linux pylatest_pip_openblas_pandas succeeded
Details
scikit-learn.scikit-learn (Linux32 py36_ubuntu_atlas_32bit)
Linux32 py36_ubuntu_atlas_32bit succeeded
Details
scikit-learn.scikit-learn (Linux_Runs pylatest_conda_mkl)
Linux_Runs pylatest_conda_mkl succeeded
Details
scikit-learn.scikit-learn (Windows py36_pip_openblas_32bit)
Windows py36_pip_openblas_32bit succeeded
Details
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
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