MNT Make sample_weight checking more consistent in regression metrics #30886
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
Ref: #30787 (comment)
What does this implement/fix? Explain your changes.
_check_reg_targets
will now performcheck_consistent_length
onsample_weight
as well asy_true
andy_pred
as well as_check_sample_weight
_check_reg_targets
, which means all checks are at the start and means we know who is raising errors relating to inputs_check_sample_weight
but AFAICT other metrics that acceptsample_weight
would also benefit from this checkAny other comments?
Not sure of what extra tests to add as
_check_sample_weight
andcheck_consistent_length
are both tested separately, and it seems redundant to check those again in the context of_check_reg_targets
.I guess I could try a few different inputs and check that the result is the same as what
_check_sample_weight
gives ?cc @ogrisel