-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
ENH Array Api support for linear, polynomial and sigmoid kernels #29475
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 Array Api support for linear, polynomial and sigmoid kernels #29475
Conversation
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.
I checked the code for polynomial_kernel
and linear_kernel
and they indeed seem to be ok if left unchanged, so just adding them to the array API test suite should indeed be enough.
Assuming CI is still green after conflict resolution, LGTM.
The CUDA run was green: https://github.com/scikit-learn/scikit-learn/actions/runs/10451046790/job/28936627899 but the status was removed from the list once I added the "waiting for reviewer" label. |
There was a random 403 error calling |
@betatim this one should be quick to review and merge and would unblock the other linked PR. |
@adrinjalali Could you kindly review this PR? I think it should be quick review. |
@@ -1537,14 +1537,16 @@ def sigmoid_kernel(X, Y=None, gamma=None, coef0=1): | ||
array([[0.76..., 0.76...], | ||
[0.87..., 0.93...]]) | ||
""" | ||
xp, _ = get_namespace(X, Y) | ||
X, Y = check_pairwise_arrays(X, Y) | ||
if gamma is None: | ||
gamma = 1.0 / X.shape[1] | ||
|
||
K = safe_sparse_dot(X, Y.T, dense_output=True) |
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.
I'm confused, safe_sparse_dot
seems to support array API, but at the end we have
But I can't find toarray
in the array API standard. So what am I missing?
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.
That part of the code only runs for sparse arrays. So it isn't linked to the array api.
…kit-learn#29475) Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Reference Issues/PRs
Towards #26024
What does this implement/fix? Explain your changes.
sklearn.pairwise
Any other comments?
CC: @ogrisel @adrinjalali @betatim
Note: I did check that the CUDA tests seem to pass.