Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[MRG] Use check_finite=False in sklearn.manifold #18886

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

Merged
merged 13 commits into from
Feb 3, 2021

Conversation

jjerphan
Copy link
Member

Reference Issues/PRs

Treats #18837 for sklearn.manifold.

What does this implement/fix? Explain your changes.

It removes the check for non-finite values on scipy.linalg functions when previous checks exist in the sklearn.manifold module.

Any other comments?

For reference:

$ git grep linalg -- sklearn | grep import | grep scipy | grep -v cython_blas | grep manifold | grep -v test | grep -v sparse.linalg
sklearn/manifold/_locally_linear.py:from scipy.linalg import eigh, svd, qr, solve
sklearn/manifold/_spectral_embedding.py:from scipy.linalg import eigh
sklearn/manifold/_t_sne.py:from scipy import linalg

I gave some indications in each commit message. The only call that I haven't modified is this one:

grad_norm = linalg.norm(grad)

This is possible as Gi is constructed from X which has been validated in
`NeighborsBase._fit`.
This is possible as Ci is constructed from Gi
which is constructed from X which has been validated
in `NeighborsBase._fit`.
This is possible as Yi is finite by construction from
the eigenvectors of Ci (which is symetric) contained in U.
X and Y contain finite values by assumption.
Hence so do C, G and trace.
v contain finite values by assumption.

Thus we can remove the check on the call to `solve`.
This is possible as X_nbrs is constructed from X which has been
validated in `NeighborsBase._fit`.
This is possible as C_nbrs is constructed from
X which has been validated in `NeighborsBase._fit`.
This is possible as Xi is constructed from X
which has been validated in `NeighborsBase._fit`.
This is possible as Ci is constructed from Gi
which is constructed from X which has been validated
in `NeighborsBase._fit`.
@jjerphan
Copy link
Member Author

@mathschy: shall you be interested again, feel free to review.

sklearn/manifold/_locally_linear.py Outdated Show resolved Hide resolved
sklearn/manifold/_locally_linear.py Outdated Show resolved Hide resolved
@mathschy
Copy link
Contributor

I just have 2 small uncertainties I do not know how to resolve myself, otherwise LGTM.

@jjerphan you may want to retry some checks in the CI ?

@mathschy
Copy link
Contributor

mathschy commented Nov 23, 2020

@jjerphan actually I think you can also add a check_finite=False in line 333 of _spectral_embedding.py because the laplacian is already checked on line 325

Edit : I finished my review

@jjerphan
Copy link
Member Author

@jjerphan you may want to retry some checks in the CI ?

It looks like the failure is unrelated to those changes — see the traces of #18883.

As @mathschy pointed out, `laplacian` is already verified line 325.
@jjerphan
Copy link
Member Author

@jjerphan actually I think you can also add a check_finite=False in line 333 of _spectral_embedding.py because the laplacian is already checked on line 325

Thanks, I've updated it in 50621ed.

as reg might not be finite.
as eigh might return non-finite values.
@jjerphan jjerphan force-pushed the duplicate_finite_check_manifold branch from 6fcf933 to b2aeaba Compare December 12, 2020 10:00
@jjerphan
Copy link
Member Author

I just have 2 small uncertainties I do not know how to resolve myself, otherwise LGTM.

@mathschy: I've reverted the checks as you proposed in e949029 and b2aeaba.

@jjerphan
Copy link
Member Author

Hi @thomasjpfan, would you also be interested to review this pull request? 🙂

sklearn/manifold/_locally_linear.py Outdated Show resolved Hide resolved
sklearn/manifold/_locally_linear.py Outdated Show resolved Hide resolved
sklearn/manifold/_locally_linear.py Outdated Show resolved Hide resolved
sklearn/manifold/_locally_linear.py Outdated Show resolved Hide resolved
sklearn/manifold/_locally_linear.py Outdated Show resolved Hide resolved
sklearn/manifold/_spectral_embedding.py Show resolved Hide resolved
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@jjerphan
Copy link
Member Author

@ogrisel: are you interested to review this (rather pretty short) PR? 🙂

Base automatically changed from master to main January 22, 2021 10:53
Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Thanks @jjerphan , LGTM.

@rth rth merged commit 74a37de into scikit-learn:main Feb 3, 2021
@jjerphan jjerphan deleted the duplicate_finite_check_manifold branch February 4, 2021 07:31
@glemaitre glemaitre mentioned this pull request Apr 22, 2021
12 tasks
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.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.