-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
EHN Add transform_inverse to Nystroem #19971
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
base: main
Are you sure you want to change the base?
EHN Add transform_inverse to Nystroem #19971
Conversation
sklearn/kernel_approximation.py
Outdated
|
|
||
| # sqrt of kernel matrix on basis vectors | ||
| U, S, V = svd(basis_kernel) | ||
| U, S, V = svd(basis_kernel) # TODO(kstoneriv3): Why not np.linalg.eigh() ? |
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 suppose eigh is faster than svd as the former is tuned specifically for Hermitian matrices. There is a comparison in the page below.
https://stackoverflow.com/questions/50358310/how-does-numpy-linalg-eigh-vs-numpy-linalg-svd
|
cc @ogrisel @lorentzenchr maybe? |
Reference Issues/PRs
As discussed in
#19732#19899,sklearn.kernel_approximation.Nystroemcurrently lackstransform_inverse()method unlikePCAandKernelPCA.What does this implement/fix? Explain your changes.
This PR implements
transform_inverseinsklearn.kernel_approximation.Nystroem.Any other comments?
While implementing the method, I was not confident about the choice of linear system solver APIs. Maybe there is a better API for solving systems with a positive semidefinite matrix.
The formula I used for kernel ridge regression of original data points to the low-dimensional representation vectors are as follows (it is also commented in the code).

The reconstruction performance was compared with KernelPCA using the example in #19945. The reconstruction quality seems identical in this case.

