pyriemann.estimation.Shrinkage¶
- class pyriemann.estimation.Shrinkage(shrinkage=0.1)¶
Regularization of SPD matrices by shrinkage.
This transformer applies a shrinkage regularization to any SPD matrix. It directly uses the shrunk_covariance function from scikit-learn [1], applied on each input.
- Parameters
- shrinkagefloat, default=0.1
Coefficient in the convex combination used for the computation of the shrunk estimate. Must be between 0 and 1.
Notes
New in version 0.2.5.
References
- __init__(shrinkage=0.1)¶
Init.
- fit(X, y=None)¶
Fit.
Do nothing. For compatibility purpose.
- Parameters
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD matrices.
- yNone
Not used, here for compatibility with sklearn API.
- Returns
- selfShrinkage instance
The Shrinkage instance.
- fit_transform(X, y=None, **fit_params)¶
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Parameters
- Xarray-like of shape (n_samples, n_features)
Input samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None
Target values (None for unsupervised transformations).
- **fit_paramsdict
Additional fit parameters.
- Returns
- X_newndarray array of shape (n_samples, n_features_new)
Transformed array.
- get_params(deep=True)¶
Get parameters for this estimator.
- Parameters
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
- paramsdict
Parameter names mapped to their values.
- set_params(**params)¶
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
- **paramsdict
Estimator parameters.
- Returns
- selfestimator instance
Estimator instance.
- transform(X)¶
Shrink and return the SPD matrices.
- Parameters
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD matrices.
- Returns
- covmatsndarray, shape (n_matrices, n_channels, n_channels)
Set of shrunk SPD matrices.