picard.picard

picard.picard(X, fun='tanh', n_components=None, ortho=True, extended=None, whiten=True, return_X_mean=False, return_n_iter=False, centering=True, max_iter=500, tol=1e-07, m=7, ls_tries=10, lambda_min=0.01, check_fun=True, w_init=None, fastica_it=None, random_state=None, verbose=False)

Perform Independent Component Analysis.

Parameters:
Xarray-like, shape (n_features, n_samples)

Training vector, where n_samples is the number of samples and n_features is the number of features.

funstr or class, optional

Either a built in density model (‘tanh’, ‘exp’ and ‘cube’), or a custom density. A custom density is a class that should contain two methods called ‘log_lik’ and ‘score_and_der’. See examples in the densities.py file.

n_componentsNone or int, optional

Number of components to extract. If None no dimension reduction is performed.

orthobool, optional

If True, uses Picard-O. Otherwise, uses the standard Picard.

extendedNone or bool, optional

If True, uses the extended algorithm to separate sub and super-gaussian sources. By default, True if ortho == True, False otherwise. Using a different density than ‘tanh’ may lead to erratic behavior of the algorithm: when extended=True, the non-linearity used by the algorithm is x +/- fun(x). The non-linearity should correspond to a density, hence fun should be dominated by x ** 2. Further, x + fun(x) should separate super-Gaussian sources and x-fun(x) should separate sub-Gaussian sources. This set of requirement is met by ‘tanh’.

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.

return_X_meanbool, optional

If True, X_mean is returned too. Equals to 0 if centering is False.

return_n_iterbool, option

Whether or not to return the number of iterations.

centeringbool, optional

If True, X is mean corrected.

max_iterint, optional

Maximum number of iterations to perform.

tolfloat, optional

A positive scalar giving the tolerance at which the un-mixing matrix is considered to have converged.

mint, optional

Size of L-BFGS’s memory.

ls_triesint, optional

Number of attempts during the backtracking line-search.

lambda_minfloat, optional

Threshold on the eigenvalues of the Hessian approximation. Any eigenvalue below lambda_min is shifted to lambda_min.

check_funbool, optionnal

Whether to check the fun provided by the user at the beginning of the run. Setting it to False is not safe.

w_initNone or (n_components, n_components) array, optional

Initial un-mixing array of dimension (n.comp,n.comp). If None (default) then a random rotation is used.

fastica_itint or None, optional (default=None)

If an int, perform fastica_it iterations of FastICA before running Picard. It might help starting from a better point.

random_stateint, RandomState instance or None, optional (default=None)

Used to perform a random initialization when w_init is not provided. 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.

verbosebool, optional

Prints informations about the state of the algorithm if True.

Returns:
Karray, shape (n_components, n_features) | None.

If whiten is ‘True’, K is the pre-whitening matrix that projects data onto the first n_components principal components. If whiten is ‘False’, K is ‘None’.

Warray, shape (n_components, n_components)

Estimated un-mixing matrix. The mixing matrix can be obtained by:

w = np.dot(W, K)
A = np.dot(w.T, np.linalg.inv(np.dot(w, w.T)))
Yarray, shape (n_components, n_samples) | None

Estimated source matrix

X_meanarray, shape (n_features,)

The mean over features. Returned only if return_X_mean is True.

n_iterint

Number of iterations taken to converge. This is returned only when return_n_iter is set to True.

Fork me on GitHub