question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FastICA G function

See original GitHub issue

sklearn.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:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JamesTrickcommented, 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 😃.

0reactions
algo-circlecommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

fastICA function - RDocumentation
In FastICA, non-gaussianity is measured using approximations to neg-entropy ( ) which are more robust than kurtosis-based measures and fast to compute. The ......
Read more >
FastICA Algorithms to Perform ICA and Projection Pursuit
the functional form of the G function used in the approximation to neg-entropy. (see 'details'). alpha constant in range [1, ...
Read more >
FastICA - Wikipedia
FastICA is an efficient and popular algorithm for independent component analysis invented by Aapo Hyvärinen at Helsinki University of Technology.
Read more >
sklearn.decomposition.FastICA
Used to initialize w_init when not specified, with a normal distribution. Pass an int, for reproducible results across multiple function calls. See Glossary....
Read more >
math/fastICA.js - Documentation
... import stat from 'pw-stat'; /** * FastICA algorithm for independent ... [options.fun=logcosh] - The functional form of the G function used in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found