Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jaffourt
Copy link
Contributor

@jaffourt jaffourt commented Oct 27, 2025

Reference Issues/PRs

Towards #26024

What does this implement/fix? Explain your changes.

Add array API support to det_curve

Any other comments?

@github-actions
Copy link

github-actions bot commented Oct 27, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: f6160c6. Link to the linter CI: here

@jaffourt
Copy link
Contributor Author

CC: @OmarManzoor @virchan @betatim @lucyleeow In case any of you have time to review :)

Copy link
Member

@lucyleeow lucyleeow left a 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)

)
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))
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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

@jaffourt
Copy link
Contributor Author

@lucyleeow Thank you for the review! I think I addressed all your comments.

Could you please disclose if you used AI to help with this PR? Thanks

Only to create the towncrier thing, the rest was me :)

@jaffourt jaffourt changed the title Add array API support to det_curve Add array API support to calinski_harabasz_score Oct 28, 2025
@jaffourt jaffourt changed the title Add array API support to calinski_harabasz_score Add array API support to det_curve Oct 28, 2025
@github-actions github-actions bot removed the CUDA CI label Oct 29, 2025
Copy link
Contributor

@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @jaffourt

@ogrisel ogrisel moved this to Todo in Array API Oct 30, 2025
@ogrisel ogrisel moved this from Todo to In Progress in Array API Oct 30, 2025
@OmarManzoor OmarManzoor added the Waiting for Second Reviewer First reviewer is done, need a second one! label Oct 30, 2025
Copy link
Member

@lucyleeow lucyleeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@lucyleeow lucyleeow merged commit b4b62d2 into scikit-learn:main Oct 31, 2025
50 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Array API Oct 31, 2025
@lucyleeow lucyleeow removed the Waiting for Second Reviewer First reviewer is done, need a second one! label Oct 31, 2025
rouk1 pushed a commit to rouk1/scikit-learn that referenced this pull request Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants