Note
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.
nilearn.connectome.GroupSparseCovariance¶
- class nilearn.connectome.GroupSparseCovariance(alpha=0.1, tol=0.001, max_iter=10, verbose=0, memory=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].
- Parameters:
- alpha
float, 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_iter
int, default=10 Maximum number of iterations for the solver. The default value is rather conservative.
- verbose
int, default=0 Verbosity level (0 means no message).
- memoryNone, instance of
joblib.Memory,str, orpathlib.Path Used to cache the masking process. By default, no caching is done. If a
stris given, it is the path to the caching directory.- memory_level
int, default=0 Rough estimator of the amount of memory used by caching. Higher value means more memory for caching. Zero means no caching.
- alpha
- Attributes:
- covariances_numpy.ndarray, shape (n_features, n_features, n_subjects)
empirical covariance matrices.
- memory_joblib memory cache
- n_features_in_
int Number of features seen during fit.
- precisions_numpy.ndarraye, shape (n_features, n_features, n_subjects)
precisions matrices estimated using the group-sparse algorithm.
References
- fit(subjects, y=None)[source]¶
Fits the group sparse precision model according to the given training data and parameters.
- Parameters:
- subjects
listof 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).
- yNone
This parameter is unused. It is solely included for scikit-learn compatibility.
- subjects
- Returns:
- selfGroupSparseCovariance instance
the object itself. Useful for chaining operations.
- get_metadata_routing()¶
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- 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_fit_request(*, subjects='$UNCHANGED$')¶
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.Added in version 1.3.
- Parameters:
- subjectsstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
subjectsparameter infit.
- Returns:
- selfobject
The updated object.
- 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.