8000 Inconsistency between fastica and FastICA · Issue #14988 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Inconsistency between fastica and FastICA #14988

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
NicolasHug opened this issue Sep 15, 2019 · 5 comments · Fixed by #14987
Closed

Inconsistency between fastica and FastICA #14988

NicolasHug opened this issue Sep 15, 2019 · 5 comments · Fixed by #14987

Comments

@NicolasHug
Copy link
Member

fastica returns W which is, according to the docs "the unmixing matrix"

FastICA has a components_ attribute which is also "the unmixing matrix"

But they are not equal when whiten is True:

if whiten == True:
	self.components_ = np.dot(unmixing, whitening)
else:
    self.components_ = unmixing

I don't know whether this is a bug (I hope it is), but if it's not the doc should be updated.

ping @agramfort

@agramfort
Copy link
Member
agramfort commented Sep 17, 2019 via email

@NicolasHug
Copy link
Member Author

Sorry I'm still confused. This is unrelated to sources as far as I understand.

The problem is that both W from fastica() and components_ from FastICA are documented as "the unmixing matrix", but they are clearly not the same thing. They don't even have the same shape.

est.components_ is equal to W.dot(est.whitening_) when whiten is True.

from sklearn.datasets import load_digits
from sklearn.decomposition import FastICA, fastica
import numpy as np

X, _ = load_digits(return_X_y=True)
whiten = True

est = FastICA(n_components=7, random_state=0, whiten=whiten).fit(X)
print(est.components_[0])  # print first comp

K, W, _ = fastica(X, n_components=7, random_state=0, whiten=whiten)
print(W.dot(est.whitening_)[0])  # equal to first comp

# according to the doc W is supposed to be the same as components_ but that's
# clearly not the case.

@agramfort
Copy link
Member
agramfort commented Sep 17, 2019 via email

@NicolasHug
Copy link
Member Author

OK so:

  1. the docs are wrong and must be updated

  2. fastica and FastICA do not have the same API: it is impossible to retrieve W (as returned by fastica) if you use FastICA.

Feel free to disagree but I see that as a problem.

@agramfort
Copy link
Member
agramfort commented Sep 18, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0