Skip to content

FIX: tol in _spectral_embedding.py #21194

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 5 commits into from
Oct 8, 2021
Merged

FIX: tol in _spectral_embedding.py #21194

merged 5 commits into from
Oct 8, 2021

Conversation

lobpcg
Copy link
Contributor

@lobpcg lobpcg commented Sep 29, 2021

Fix the typo in tol from -15 to -5, making it consistent with other calls of lobpcg here.

Reference Issues/PRs

Fixes #21147

What does this implement/fix? Explain your changes.

Excessively small tol in lobpcg not only makes it unnecessary slower, increasing the number of iterations for no good reason, but can also make it fail due to numerical instabilities, as found in #21147

Any other comments?

Fix the typo in tol from -15 to -5
@lobpcg lobpcg changed the title Update _spectral_embedding.py {MRG] Bug fix: tol in _spectral_embedding.py Sep 29, 2021
@lobpcg lobpcg changed the title {MRG] Bug fix: tol in _spectral_embedding.py [MRG] Bug fix: tol in _spectral_embedding.py Sep 29, 2021
@ogrisel
Copy link
Member

ogrisel commented Oct 6, 2021

Excessively small tol in lobpcg not only makes it unnecessary slower, increasing the number of iterations for no good reason, but can also make it fail due to numerical instabilities, as found in #21147

Would it be possible to add a non regression test inspired by #21147 but using a small synthetic dataset?

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM since the existing tests do not fail. It would be great to have a new non-regression test as explained above but I would not hold the merge of this PR for this if it's too complex to craft such a non-regression test (given the fact that it should also be fast to run, ideally in less than 100ms).

@ogrisel
Copy link
Member

ogrisel commented Oct 6, 2021

We also need an entry for the changelog targeting 1.0.1 (in doc/whats_new/v1.0.rst) if done quickly or alternatively 1.1 (in doc/whats_new/v1.1.rst).

Added info on #21194
lobpcg added 3 commits October 6, 2021 13:16
A unit test added
moved for the proper order
wrong file edited! Back to the original
@lobpcg
Copy link
Contributor Author

lobpcg commented Oct 6, 2021

@ogrisel - It's difficult to make a direct unit test without using that specific matrix presented in the original file, since the example needs to reproduce the logic where the default solver, arpack, fails and falls back till it finally reaches lobpcg, which is the last line of defense in the code.

@ogrisel
Copy link
Member

ogrisel commented Oct 7, 2021

+1 for new issues to analyse the bugs you found while trying to work on a new test.

@lobpcg
Copy link
Contributor Author

lobpcg commented Oct 7, 2021

+1 for new issues to analysis the bugs you found while trying to work on a new test.

SpectralClustering breaks on small-size low-rank data #21274

Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for your involvement in the project with this contribution and with on-going others, @lobpcg! 👍

@thomasjpfan thomasjpfan changed the title [MRG] Bug fix: tol in _spectral_embedding.py FIX: tol in _spectral_embedding.py Oct 8, 2021
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

@thomasjpfan thomasjpfan merged commit 8b18d4c into scikit-learn:main Oct 8, 2021
@lobpcg lobpcg deleted the patch-2 branch October 8, 2021 20:29
@glemaitre glemaitre mentioned this pull request Oct 23, 2021
10 tasks
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Oct 23, 2021
glemaitre pushed a commit that referenced this pull request Oct 25, 2021
samronsin pushed a commit to samronsin/scikit-learn that referenced this pull request Nov 30, 2021
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.

SpectralClustering() ValueError: expected 1-d or 2-d array or matrix, got array(None, dtype=object)
4 participants