Skip to content

Add user option to use SVD for orthogonalizing the mixing matrix in FastICA #2738

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

Closed
wants to merge 2 commits into from

Conversation

alimuldal
Copy link

It seems that the current eigendecomposition-based method for orthogonalizing the mixing matrix in sklearn.decomp.fastica is less numerically stable and produces a less orthogonal output than using a different SVD-based strategy. In some cases, the original method yields NaNs in the result, resulting in a ValueError exception that does not occur with the new SVD-based method. However, there seems to be a trade-off between speed and quality, as the new method is not quite as fast as the original - see the extended discussion in #2735.

I've added another boolean keyword argument to fastica and to the FastICA class to enable the use of the SVD-based method rather than the original eigendecomposition-based method.

Quality

ortho_closeness

Speed

ortho_bench

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling d4344f5 on alimuldal:fastica_svd_decorr into b3a9da9 on scikit-learn:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling d4344f5 on alimuldal:fastica_svd_decorr into b3a9da9 on scikit-learn:master.

@dengemann
Copy link
Contributor

@alimuldal @GaelVaroquaux

I've run some basic performance benchmarks and I don't think the changes will incur meaningful costs.

proposed changes with both options:
fastica-1gb-svd-decorr

0-15-git master:
fastica-1gb-015-git

Also see:
https://gist.github.com/dengemann/9091092

@dengemann
Copy link
Contributor

I'll soon check whether the new options improve estimation in a few applications of mine. For the PR this should not be relevant though.

@dengemann
Copy link
Contributor

Here's another performance plot with more realistic parameters (50 components, 250k samples, 250 features). We now clearly see the difference.

fastica-500gb-svd-decorr-realistic-data

I think that's fair enough given that one can choose between both options.

@rphlypo
Copy link

rphlypo commented Feb 19, 2014

Just want to pull your attention to the following observation nilearn/nilearn#152, discussing a similar case, but in which we have opted to change from the scipy.linalg.svd with the option full_matrices = False to a symmetric eigenvalue decomposition (the former is problematic if numpy is compiled against lapack_lite)

@GaelVaroquaux
Copy link
Member

Base on the fact that numpy compiled with lapack_lite will generate
problems in the case of the SVD, I suggest that:

  • We remove the option svd_decorr: too many options end up being
    confusing for the user
  • We default to using SVD
  • If numpy is compiled with lapack_lite, we raise a meaningful warning,
    and use eigsh

To check if numpy is compiled with lapack_lite, you can try to import
numpy.core._dotblas. If the import fails, numpy is compiled with
lapack_lite.

@dengemann
Copy link
Contributor

@GaelVaroquaux +1 for your proposal. However, to fully embrace not adding a new option I first need to see some down-stream improvements in analyses. On the other hand, we can still add the option later if it turns out relevant.

@GaelVaroquaux
Copy link
Member

However, to fully embrace not adding a new option I first need to see
some down-stream improvements in analyses.

For the original poster, it lead to an improvement.

@dengemann
Copy link
Contributor

For the original poster, it lead to an improvement.

Then let's add it for now. Probably it's a good bet and I'll be happy too. If not I'll report + propose changes.

@dengemann
Copy link
Contributor

@GaelVaroquaux @agramfort
Btw. 'svd_deorr=True' as internal default would not affect MNE tests + examples.
Good to go from my side.

@amueller
Copy link
Member

what is the status on this?

@agramfort
Copy link
Member

is the improvement significant? what's the gain?

@haiatn
Copy link
Contributor

haiatn commented Aug 25, 2023

I see that FastICA now had a whiten_solver that has a SVD option, does this mean this PR is not needed anymore? And what does it mean about the issue?

@agramfort
Copy link
Member

yes.

thanks @haiatn for chasing outdated PRs

and thanks @alimuldal for your effort here.

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.

8 participants