picard.Picard

class picard.Picard(n_components=None, *, ortho=True, extended=None, whiten=True, fun='tanh', max_iter=500, tol=1e-07, w_init=None, m=7, ls_tries=10, lambda_min=0.01, random_state=None)

Picard: a very fast algorithm for Independent Component Analysis.

Parameters:
n_componentsint, default=None

Number of components to use. If None is passed, all are used.

orthobool, optional

If True, uses Picard-O and enforce an orthogonal constraint. Otherwise, uses the standard Picard.

extendedNone or bool, optional

If True, uses the extended algorithm to separate sub and super-gaussian sources. If None (default), it is set to True if ortho == True, and False otherwise. With extended=True we recommend you keep the different density to ‘tanh’. See notes below.

whitenbool, default=True

If whiten is false, the data is already considered to be whitened, and no whitening is performed.

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.

max_iterint, default=500

Maximum number of iterations during fit.

tolfloat, default=1e-7

Tolerance on update at each iteration.

w_initndarray of shape (n_components, n_components), default=None

The mixing matrix to be used to initialize the algorithm.

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.

random_stateint, RandomState instance or None, default=None

Used to initialize w_init when not specified, with a normal distribution. Pass an int, for reproducible results across multiple function calls.

Notes

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’.

Examples

>>> from sklearn.datasets import load_digits
>>> from picard import Picard
>>> X, _ = load_digits(return_X_y=True)
>>> transformer = Picard(n_components=7,
...         random_state=0)
>>> X_transformed = transformer.fit_transform(X)
>>> X_transformed.shape
(1797, 7)
Attributes:
components_ndarray of shape (n_components, n_features)

The linear operator to apply to the data to get the independent sources. This is equal to the unmixing matrix when whiten is False, and equal to np.dot(unmixing_matrix, self.whitening_) when whiten is True.

mixing_ndarray of shape (n_features, n_components)

The pseudo-inverse of components_. It is the linear operator that maps independent sources to the data.

mean_ndarray of shape(n_features,)

The mean over features. Only set if self.whiten is True.

whitening_ndarray of shape (n_components, n_features)

Only set if whiten is ‘True’. This is the pre-whitening matrix that projects data onto the first n_components principal components.

Methods

fit(X[, y])

Fit the model to X.

fit_transform(X[, y])

Fit the model and recover the sources from X.

get_feature_names_out([input_features])

Get output feature names for transformation.

get_params([deep])

Get parameters for this estimator.

inverse_transform(X[, copy])

Transform the sources back to the mixed data (apply mixing matrix).

set_params(**params)

Set the parameters of this estimator.

transform(X[, copy])

Recover the sources from X (apply the unmixing matrix).

__init__(n_components=None, *, ortho=True, extended=None, whiten=True, fun='tanh', max_iter=500, tol=1e-07, w_init=None, m=7, ls_tries=10, lambda_min=0.01, random_state=None)

Methods

__init__([n_components, ortho, extended, ...])

fit(X[, y])

Fit the model to X.

fit_transform(X[, y])

Fit the model and recover the sources from X.

get_feature_names_out([input_features])

Get output feature names for transformation.

get_params([deep])

Get parameters for this estimator.

inverse_transform(X[, copy])

Transform the sources back to the mixed data (apply mixing matrix).

set_params(**params)

Set the parameters of this estimator.

transform(X[, copy])

Recover the sources from X (apply the unmixing matrix).

Fork me on GitHub