Giving credit

Previous topic

7.1.1. nilearn.connectome.ConnectivityMeasure

Next topic

7.1.3. nilearn.connectome.GroupSparseCovarianceCV


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.

7.1.2. nilearn.connectome.GroupSparseCovariance

class nilearn.connectome.GroupSparseCovariance(alpha=0.1, tol=0.001, max_iter=10, verbose=0, memory=Memory(cachedir=None), memory_level=0)

Covariance and precision matrix estimator.


alpha : float

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)

tol : positive float, optional

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

max_iter : int, optional

maximum number of iterations. The default value (10) is rather conservative.

verbose : int, optional

verbosity level. Zero means “no message”.

memory : instance 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_level : int, optional

Caching aggressiveness. Higher values mean more caching.


The model used has been introduced in:

Gael Varoquaux, et al. Brain Covariance Selection: Better Individual Functional Connectivity Models Using Population Prior‘.

The algorithm used is based on what is described in:

Jean Honorio and Dimitris Samaras. “Simultaneous and Group-Sparse Multi-Task Learning of Gaussian Graphical Models”.


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(cachedir=None), memory_level=0)
fit(subjects, y=None)

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


subjects : list 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).


self : GroupSparseCovariance instance

the object itself. Useful for chaining operations.


Get parameters for this estimator.


deep: boolean, optional

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


params : mapping of string to any

Parameter names mapped to their values.


Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.