-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
ENH Add array api support for precision, recall and fbeta_score #30395
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
ENH Add array api support for precision, recall and fbeta_score #30395
Conversation
virchan
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! Just one minor suggestion:
|
LGTM, just one question about removing the assert statement. |
|
@ogrisel Do you think we can merge this PR? |
sklearn/metrics/_classification.py
Outdated
| denom = beta2 * xp.asarray( | ||
| true_sum, dtype=max_float_type, device=device_ | ||
| ) + xp.asarray(pred_sum, dtype=max_float_type, 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.
shouldn't true_sum and pred_sum already be on the device? I don't like that a simple multiplication and sum has become such a long piece of code.
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.
Array api strict is the only one which causes such issues. They require that the arrays be of the same type. Over here since beta2 is a float it doesn't accept ints and raises the following error:
TypeError: array_api_strict.float64 and array_api_strict.int64 cannot be type promoted together
Anyways I made some changes to only cast it to the correct dtype.
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.
Note: I verified that the CUDA tests work fine on a kaggle kernel
| check_array_api_multilabel_classification_metric, | ||
| ], | ||
| fbeta_score: [ | ||
| check_array_api_multiclass_classification_metric, |
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.
@OmarManzoor naive question - why not include check_array_api_binary_classification_metric here?
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.
If it works for the binary case I think we can include it.
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.
Ah thanks! I was just wondering if it was left out for a specific reason!
Reference Issues/PRs
Towards #26024
What does this implement/fix? Explain your changes.
Any other comments?
CC: @ogrisel @adrinjalali