sklearn.decomposition
.fastica¶

sklearn.decomposition.
fastica
(X, n_components=None, algorithm='parallel', whiten=True, fun='logcosh', fun_args=None, max_iter=200, tol=0.0001, w_init=None, random_state=None, return_X_mean=False, compute_sources=True, return_n_iter=False)[source]¶ Perform Fast Independent Component Analysis.
Read more in the User Guide.
 Parameters
 Xarraylike, shape (n_samples, n_features)
Training vector, where n_samples is the number of samples and n_features is the number of features.
 n_componentsint, optional
Number of components to extract. If None no dimension reduction is performed.
 algorithm{‘parallel’, ‘deflation’}, optional
Apply a parallel or deflational FASTICA algorithm.
 whitenboolean, optional
If True perform an initial whitening of the data. If False, the data is assumed to have already been preprocessed: it should be centered, normed and white. Otherwise you will get incorrect results. In this case the parameter n_components will be ignored.
 funstring or function, optional. Default: ‘logcosh’
The functional form of the G function used in the approximation to negentropy. Could be either ‘logcosh’, ‘exp’, or ‘cube’. You can also provide your own function. It should return a tuple containing the value of the function, and of its derivative, in the point. The derivative should be averaged along its last dimension. Example:
 def my_g(x):
return x ** 3, np.mean(3 * x ** 2, axis=1)
 fun_argsdictionary, optional
Arguments to send to the functional form. If empty or None and if fun=’logcosh’, fun_args will take value {‘alpha’ : 1.0}
 max_iterint, optional
Maximum number of iterations to perform.
 tolfloat, optional
A positive scalar giving the tolerance at which the unmixing matrix is considered to have converged.
 w_init(n_components, n_components) array, optional
Initial unmixing array of dimension (n.comp,n.comp). If None (default) then an array of normal r.v.’s is used.
 random_stateint, RandomState instance or None, optional (default=None)
If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by
np.random
. return_X_meanbool, optional
If True, X_mean is returned too.
 compute_sourcesbool, optional
If False, sources are not computed, but only the rotation matrix. This can save memory when working with big data. Defaults to True.
 return_n_iterbool, optional
Whether or not to return the number of iterations.
 Returns
 Karray, shape (n_components, n_features)  None.
If whiten is ‘True’, K is the prewhitening matrix that projects data onto the first n_components principal components. If whiten is ‘False’, K is ‘None’.
 Warray, shape (n_components, n_components)
The square matrix that unmixes the data after whitening. The mixing matrix is the pseudoinverse of matrix
W K
if K is not None, else it is the inverse of W. Sarray, shape (n_samples, n_components)  None
Estimated source matrix
 X_meanarray, shape (n_features, )
The mean over features. Returned only if return_X_mean is True.
 n_iterint
If the algorithm is “deflation”, n_iter is the maximum number of iterations run across all components. Else they are just the number of iterations taken to converge. This is returned only when return_n_iter is set to
True
.
Notes
The data matrix X is considered to be a linear combination of nonGaussian (independent) components i.e. X = AS where columns of S contain the independent components and A is a linear mixing matrix. In short ICA attempts to
unmix' the data by estimating an unmixing matrix W where ``S = W K X.`
While FastICA was proposed to estimate as many sources as features, it is possible to estimate less by setting n_components < n_features. It this case K is not a square matrix and the estimated A is the pseudoinverse ofW K
.This implementation was originally made for data of shape [n_features, n_samples]. Now the input is transposed before the algorithm is applied. This makes it slightly faster for Fortranordered input.
Implemented using FastICA: A. Hyvarinen and E. Oja, Independent Component Analysis: Algorithms and Applications, Neural Networks, 13(45), 2000, pp. 411430