Skip to content

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

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

Conversation

kstoneriv3
Copy link
Contributor

@kstoneriv3 kstoneriv3 commented Apr 24, 2021

Reference Issues/PRs

As discussed in #19732 #19899, sklearn.kernel_approximation.Nystroem currently lacks transform_inverse() method unlike PCA and KernelPCA.

What does this implement/fix? Explain your changes.

This PR implements transform_inverse in sklearn.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).
image

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

@@ -778,11 +836,17 @@ def fit(self, X, y=None):
**self._get_kernel_params())

# 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() ?
Copy link
Contributor Author

@kstoneriv3 kstoneriv3 Apr 24, 2021

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

@adrinjalali
Copy link
Member

cc @ogrisel @lorentzenchr maybe?

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

Successfully merging this pull request may close these issues.

2 participants