Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix for spectral clustering error when using 'amg' solver #13707
What does this implement/fix? Explain your changes.
Fixes LinAlgError when using spectral clustering with the
Any other comments?
This PR is derived from the previous PR #12316 submitted by Andrew Knyazev (lobpcg). In that PR, Andrew fixed issue #13393 and also added a new label assignment option 'clusterQR'. It was requested that the PR be split to separate the fix and the new label assignment functionality. This PR contains Andrew's fix for the AMG bug.
Thanks for this @whitews
I'm not sure what chance it has to get into 0.21, but just in case:
I think that the mathematically proper fix is changing in sklearn/manifold/spectral_embedding_.py the present
so that the LOBPCG solver is still called on the unchanged Laplacian, but only the AMG preconditioner is fed with the shifted Laplacian. I have updated my #13393 to highlight this.
I am unsure how the memory allocation would work in my suggestion above. May be to save memory one can do something like:
https://scikit-learn.org/stable/modules/generated/sklearn.cluster.spectral_clustering.html, says that using amg eigen solver may lead to instabilities. This can be now removed, I think.