FastICA G function
See original GitHub issuesklearn.decomposition.FastICA throws broadcast error when g function aregument is present
import numpy as np
from sklearn.decomposition import FastICA
t=np.linspace(0,2*np.pi)
S=np.c_[np.sin(t),np.cos(2*t)]
def my_g(x):
return x**3,3*x**2 # from documents
ica=FastICA(fun=my_g)
ica.fit(S)
Which throws:
Traceback (most recent call last):
File “<ipython-input-25-24d34523b2be>”, line 1, in <module> 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)
Versions
Windows-7-6.1.7601-SP1 NumPy 1.13.3 SciPy 1.1.0 Scikit-Learn 0.19.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
@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 😃.
@JamesTrick
Thank you for the help. I’ll be working on this issue now. Will soon make a pull request regarding the same.