FIX binary y in sample weight equivalence check#30775
Merged
jeremiedbb merged 6 commits intoFeb 10, 2025
Merged
Conversation
ogrisel
approved these changes
Feb 7, 2025
ogrisel
left a comment
Member
There was a problem hiding this comment.
Thanks, @antoinebaker. Can you please add a fix changelog entry? Other than that, LGTM.
jeremiedbb
approved these changes
Feb 7, 2025
jeremiedbb
left a comment
Member
There was a problem hiding this comment.
LGTM. Just 1 question below
jeremiedbb
reviewed
Feb 10, 2025
| @@ -0,0 +1,7 @@ | |||
| - :func:`utils.estimator_checks._enforce_estimator_tags_y` enforces a binary `y` | |||
Member
There was a problem hiding this comment.
Let's not reference the private API in the changelog. We just need to mention that the 2 checks have been for binary targets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Fixes #30770. Thanks a lot @pierrenodet for the bug report!
What does this implement/fix? Explain your changes.
The
_enforce_estimator_tags_yallows to convert a genericyto a binary one for estimators that require it (binary classifiers). Unfortunately the current method (taking the first element as the negative class) is sensitive to shuffling and_check_sample_weight_equivalenceconvertsyafter shuffling, which makes the_check_sample_weight_equivalencewrongly fail on binary classifiers.This PR takes
y.min()as the negative class to make_enforce_estimator_tags_yinsensitive to shuffling.