This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.


class nilearn.connectome.GroupSparseCovariance(alpha=0.1, tol=0.001, max_iter=10, verbose=0, memory=Memory(location=None), memory_level=0)[source]#

Covariance and precision matrix estimator.

The model used has been introduced in Varoquaux et al.[1], and the algorithm used is based on what is described in Honorio et al.[2].

alphafloat, default=0.1

regularization parameter. With normalized covariances matrices and number of samples, sensible values lie in the [0, 1] range(zero is no regularization: output is not sparse).

tolpositive float, default=1e-3

The tolerance to declare convergence: if the dual gap goes below this value, iterations are stopped.

max_iterint, default=10

maximum number of iterations. The default value is rather conservative.

verboseint, default=0

verbosity level. Zero means “no message”.

memoryinstance of joblib.Memory or string, optional

Used to cache the masking process. By default, no caching is done. If a string is given, it is the path to the caching directory.

memory_levelint, default=0

Caching aggressiveness. Higher values mean more caching.


covariances_numpy.ndarray, shape (n_features, n_features, n_subjects)

empirical covariance matrices.

precisions_numpy.ndarraye, shape (n_features, n_features, n_subjects)

precisions matrices estimated using the group-sparse algorithm.

__init__(alpha=0.1, tol=0.001, max_iter=10, verbose=0, memory=Memory(location=None), memory_level=0)[source]#
fit(subjects, y=None)[source]#

Fits the group sparse precision model according to the given training data and parameters.

subjectslist of numpy.ndarray with shapes (n_samples, n_features)

input subjects. Each subject is a 2D array, whose columns contain signals. Sample number can vary from subject to subject, but all subjects must have the same number of features (i.e. of columns).

selfGroupSparseCovariance instance

the object itself. Useful for chaining operations.


Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.


A MetadataRequest encapsulating routing information.


Get parameters for this estimator.

deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.


Parameter names mapped to their values.

set_fit_request(*, subjects='$UNCHANGED$')#

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.


This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

subjectsstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for subjects parameter in fit.


The updated object.


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.


Estimator parameters.

selfestimator instance

Estimator instance.