Skip to content

ENH add Array API support for d2_pinball_score and d2_absolute_error_score #31671

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

virchan
Copy link
Member

@virchan virchan commented Jun 28, 2025

Reference Issues/PRs

Towards #26024

What does this implement/fix? Explain your changes.

Adds Array API support for d2_pinball_score and d2_absolute_error_score.

Any other comments?

N/A

Copy link

github-actions bot commented Jun 28, 2025

✔️ Linting Passed

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

Generated for commit: 133d82a. Link to the linter CI: here

@virchan virchan changed the title add Array API support to d2_absolute_error_score and `d2_pinball_sc… ENH add Array API support for d2_pinball_score and d2_absolute_error_score Jun 28, 2025
Copy link
Member Author

@virchan virchan left a comment

Choose a reason for hiding this comment

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

I think we need to add Array API support for the quantile function to handle cases where sample_weight is None. I'll work on that later.

@lucyleeow
Copy link
Member

Scipy quantile now supports array API (but not weights): scipy/scipy#22352

Their quantile function is probably (?) faster than ours (benchmarking needed) and it would be nice to not maintain another array API function. But it was added after our min scipy.

I'll open an RFC issue about adding quantile to array api extra, it's been on my todo for a while.

@lucyleeow
Copy link
Member

data-apis/array-api-extra#340 may take a long while, so we should still decide here what we want to do, even if it is 'temporary'.

@virchan
Copy link
Member Author

virchan commented Jun 30, 2025

Thanks @lucyleeow!

@OmarManzoor
Copy link
Contributor

OmarManzoor commented Jun 30, 2025

Do we really need a dedicated implementation for quantile in array-api-extra when all the relevant array api libraries support it (I checked that dask and jax also support this aside from cupy and Pytorch)? Maybe all we actually need is a helper that can call the respective function of the library under consideration (Pytorch has a different name for the dim parameter) and simply convert to numpy to handle array-api-strict.

@lucascolley
Copy link
Contributor

Do we really need a dedicated implementation for quantile in array-api-extra when all the relevant array api libraries support it

  1. The dedicated implementation should not be too difficult, as https://github.com/scipy/scipy/blob/main/scipy/stats/_quantile.py already supports the standard

  2. The delegation to existing libraries you describe can be covered by array-api-extra too: https://github.com/data-apis/array-api-extra/blob/main/src/array_api_extra/_delegation.py

@OmarManzoor
Copy link
Contributor

  1. The delegation to existing libraries you describe can be covered by array-api-extra too: https://github.com/data-apis/array-api-extra/blob/main/src/array_api_extra/_delegation.py

@lucascolley Thanks for the feedback. I think it makes sense to add it there then. Do we need a new implementation though when we don't really need it? I guess it would require copying the relevant code from scipy?

@lucascolley
Copy link
Contributor

Do we need a new implementation though when we don't really need it?

Yes, it is good to future-proof and not rely on existing libraries. cf. Tim's comment over at data-apis/array-api-extra#340 (comment) let's continue discussion over there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants