Repository navigation
FIX Validate sample_weight in ranking metrics and hinge_loss - #35512
Jeremy891102 wants to merge 8 commits into
Conversation
|
Thank you for opening your first pull request to scikit-learn! 🎉 To help get your contribution reviewed, please make sure that:
|
|
CI failed at first because |
…ics-sample-weight
virchan
left a comment
There was a problem hiding this comment.
Thank you for the PR, @Jeremy891102.
CONTINUOUS_CLASSIFICATION_METRICS is not a subset of CLASSIFICATION_METRICS. Therefore, the new test is independent of the existing test_classification_with_invalid_sample_weight, and seems appropriate.
I also have a few comments below. Otherwise, LGTM.
| if sample_weight is not None: | ||
| sample_weight = _check_sample_weight( | ||
| sample_weight, y_score, force_float_dtype=False | ||
| ) |
There was a problem hiding this comment.
Let's move this a few blocks earlier. Ideally, all input validation should be completed before calling move_to.
Co-authored-by: Virgil Chan <[email protected]>
….com/Jeremy891102/scikit-learn into fix-continuous-metrics-sample-weight
Reference Issues/PRs
Fixes #35487. See also #32212.
What does this implement/fix? Explain your changes.
When
sample_weightis given, the metrics listed in #35487 now call_check_sample_weightto validate it. They were missed before because they don't go through_check_targets, so the change in #32212 did not cover them. I added a common test that checks the invalid weights for all ofCONTINUOUS_CLASSIFICATION_METRICS. Before this change, they returnednanor0, or raised unrelated errors; now they raise the sameValueErroras the other metrics. The behavior for valid weights does not change.Introduce yourself
I'm a second-year master's student working on ML for healthcare projects and agentic AI systems.
AI usage disclosure
I used AI assistance for:
Any other comments?