Move mixed array input support of regression metrics to _check_reg_targets - #33778
Conversation
| y_true, sample_weight = move_to(y_true, sample_weight, xp=xp, device=device) | ||
| xp, _, device_ = get_namespace_and_device(y_pred) | ||
| _, y_true, y_pred, sample_weight, multioutput = ( | ||
| _check_reg_targets_with_floating_dtype( |
There was a problem hiding this comment.
I've added _check_reg_targets_with_floating_dtype here, even though it was not here previously, as it calls mean_squared_error, which performs this check because multioutput is otherwise not checked to ensure it is valid. This makes it more consistent, ensuring the same informative error is raised if multioutput is not valid
|
Some tests fail with pandas inputs. I haven't looked at the details but feel free to ping me again once you have a fix for this. |
|
I think this is ready for a review now @ogrisel, thank you! |
I mean that it's not possible to cross-validate regression pipelines that move X to GPU in some intermediate step with any of the supported regression metrics from the updated Basically the kind of thing I was trying to get working in |
| # `torch.median` takes the lower of the two medians when `x` has even number | ||
| # of elements, thus we use `torch.quantile(q=0.5)`, which gives mean of the two | ||
| if array_api_compat.is_torch_namespace(xp): | ||
| # torch `quantile` only accepts floats |
There was a problem hiding this comment.
+1 for adding a new test case for int inputs for _array_api.py functions. Feel free to ping me once done.
Sorry, I wasn't sure if you were referring to something else. I've double checked and everything was already covered in #33515 and #33511 - there are 21 metrics in |
|
ping @virchan @OmarManzoor |
OmarManzoor
left a comment
There was a problem hiding this comment.
Mostly looks good just a few comments. Thank you for the PR @lucyleeow
Co-authored-by: Omar Salman <[email protected]>
e05aed0 to
5d91885
Compare
OmarManzoor
left a comment
There was a problem hiding this comment.
LGTM. Thank you @lucyleeow
…argets` (scikit-learn#33778) Co-authored-by: Omar Salman <[email protected]>
Reference Issues/PRs
Towards #33519 (still need to address for classification metrics and add appropriate tests)
Follows from #32755
As discussed in #33515 (comment)
Based off of @ogrisel 's work in https://github.com/scikit-learn/scikit-learn/pull/32873/files#diff-937b82251fd52d1911b5046edef599c244a155f70b00d730f1eeb25be133a8a1 (see thread #32755 (comment))
What does this implement/fix? Explain your changes.
Adds support of mixed array namespace/device input to the common
_check_reg_targetsthat is used in all regression metrics. This means that all regression metrics automatically support mixed array inputs when it uses_check_reg_targetsAI usage disclosure
I used AI assistance for:
Any other comments?
No changelog as I think all reg metrics already supported mixed array inputs.