Skip to content

FIX: tol in _spectral_embedding.py - #21194

Merged
thomasjpfan merged 5 commits into
scikit-learn:mainfrom
lobpcg:patch-2
Oct 8, 2021
Merged

thomasjpfan merged 5 commits into
scikit-learn:mainfrom
lobpcg:patch-2

Conversation

@lobpcg

@lobpcg lobpcg commented Sep 29, 2021 •

Copy link
Copy Markdown
Contributor

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

ogrisel commented Oct 6, 2021

Copy link
Copy Markdown
Member

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?

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

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

ogrisel commented Oct 6, 2021

Copy link
Copy Markdown
Member

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
Comment thread doc/whats_new/v1.0.rst Resolved
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

lobpcg commented Oct 6, 2021 •

Copy link
Copy Markdown
Contributor Author

@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

ogrisel commented Oct 7, 2021 •

Copy link
Copy Markdown
Member

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

@lobpcg

lobpcg commented Oct 7, 2021

Copy link
Copy Markdown
Contributor Author

+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

@jjerphan jjerphan left a comment

Copy link
Copy Markdown
Member

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

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

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
8 of 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