You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sklearn.decomposition.FastICA throws broadcast error when g function aregument is present
importnumpyasnpfromsklearn.decompositionimportFastICAt=np.linspace(0,2*np.pi)
S=np.c_[np.sin(t),np.cos(2*t)]
defmy_g(x):
returnx**3,3*x**2# from documentsica=FastICA(fun=my_g)
ica.fit(S)
Which throws:
Traceback (most recent call last):
File "", line 1, in
ica.fit(S.T)
File "C:\Users\mhossein\Anaconda3\lib\site-packages\sklearn\decomposition\fastica_.py", line 535, in fit
self._fit(X, compute_sources=False)
File "C:\Users\mhossein\Anaconda3\lib\site-packages\sklearn\decomposition\fastica_.py", line 487, in _fit
compute_sources=compute_sources, return_n_iter=True)
File "C:\Users\mhossein\Anaconda3\lib\site-packages\sklearn\decomposition\fastica_.py", line 340, in fastica
W, n_iter = _ica_par(X1, **kwargs)
File "C:\Users\mhossein\Anaconda3\lib\site-packages\sklearn\decomposition\fastica_.py", line 110, in _ica_par
- g_wtx[:, np.newaxis] * W)
ValueError: operands could not be broadcast together with shapes (2,1,50) (2,2)
@adrinjalali
I was looking through the documentation and checked the sklearn/decomposition/fastica_.py file but couldn't figure out a way to fix this issue. Could you tell a little bit more about this issue and how to approach this one as I am new to Open Source contributions but nevertheless keen to contribute to the organization.
Activity
adrinjalali commentedon Feb 6, 2019
Seems like a documentation error, the tests have it as:
Mahdi-Hosseinali commentedon Feb 6, 2019
That's right, it works when I add the mean.
algo-circle commentedon Feb 7, 2019
@adrinjalali
I was looking through the documentation and checked the
sklearn/decomposition/fastica_.pyfile but couldn't figure out a way to fix this issue. Could you tell a little bit more about this issue and how to approach this one as I am new to Open Source contributions but nevertheless keen to contribute to the organization.JamesTrick commentedon Feb 7, 2019
@algo-circle
Start by searching the repo for the function
my_g(x)and you should find the relevant piece of documentation here.For general contributing to open source, I found this guide pretty helpful just to understand the git workflow :).
algo-circle commentedon Feb 8, 2019
@JamesTrick
Thank you for the help. I'll be working on this issue now. Will soon make a pull request regarding the same.