-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Add array API support to det_curve
#32586
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
|
CC: @OmarManzoor @virchan @betatim @lucyleeow In case any of you have time to review :) |
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.
Thanks for your contribution.
Could you please disclose if you used AI to help with this PR? Thanks
(please see: https://scikit-learn.org/dev/developers/contributing.html#automated-contributions-policy)
sklearn/utils/validation.py
Outdated
| ) | ||
| or xp.all(classes == xp.asarray([0], dtype=cls_dtype, device=device)) | ||
| or xp.all(classes == xp.asarray([-1], dtype=cls_dtype, device=device)) | ||
| or xp.all(classes == xp.asarray([1], dtype=cls_dtype, device=device)) |
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.
Can you expand on why this change was needed?
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.
Maybe this is superfluous for this PR now that I've removed the custom unit test and am using sklearn/metrics/tests/test_common.py.
The previous API compatibility change to precision_recall_curve didn't raise this issue AFAICT because the test check_array_api_binary_classification_metric only uses integer values for y_true_np.
If y_true_np is floating, then _check_pos_label_consistency raises an error comparing floats to ints.
I added this step to ensure the dtypes align when y_true_np is floating -- however given this is a binary classification metric, do we want silent conversions or should we just fail when the input arrays are floating?
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.
We always assume y_true to be int; sklearn estimators would not output labels as floats. We also often use np.unique on true labels, which isn't ideal with floats due to floating point precision.
Others can comment more but changing to allow labels to be floats would need to be discussed and would be outside the scope of this PR.
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.
Good point, I'll just remove this change
|
@lucyleeow Thank you for the review! I think I addressed all your comments.
Only to create the towncrier thing, the rest was me :) |
This reverts commit 54f4b53.
det_curvecalinski_harabasz_score
calinski_harabasz_scoredet_curve
OmarManzoor
left a comment
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.
LGTM. Thanks @jaffourt
lucyleeow
left a comment
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.
LGTM thanks!
Co-authored-by: Lucy Liu <[email protected]>
Reference Issues/PRs
Towards #26024
What does this implement/fix? Explain your changes.
Add array API support to
det_curveAny other comments?