-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FIX utils.multiclass.type_of_target with numpy 1.24 dev #24044
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
Conversation
The scipy-dev build fails since there are still some errors to fix there, but there are no more errors like the one below which shows that the fix works for numpy 1.24dev:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we actually support jagged arrays as a target. After the jagged array is created, I think we always raise a more detailed error. Some of this behavior is tested in test_raise_value_error_multilabel_sequences
.
As a quick fix, I am okay with this PR.
Thanks @lesteve |
…#24044) Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
…#24044) Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Seen in #23626.
In numpy 1.24dev,
np.array([[1], [1, 2]])
raises aValueError
you need to specifydtype=object
explicitly.See https://numpy.org/neps/nep-0034-infer-dtype-is-object.html for more details.
I think this was an oversight in #18423.
Not super familiar with the
sklearn.utils.multicass.type_of_target/is_multilabel
details, but I am wondering whether we could simplify the code and usey = np.asarray(y, dtype=object)
. Maybe we rely on the inferred dtype in the non-ragged array-like case. Edit: looks like we are sincepytest sklearn/utils/tests/test_multiclass.py
fails when trying to use my naive simplification.