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.
8.8.9. nilearn.regions.ReNA¶
- class
nilearn.regions.
ReNA
(mask_img, n_clusters=2, scaling=False, n_iter=10, threshold=1e-07, memory=None, memory_level=1, verbose=0)¶ Recursive Neighbor Agglomeration (ReNA): Recursively merges the pair of clusters according to 1-nearest neighbors criterion [1].
- Parameters
- mask_imgNiimg-like object
Object used for masking the data.
- n_clustersint, optional
The number of clusters to find. Default=2.
- scalingbool, optional
If scaling is True, each cluster is scaled by the square root of its size, preserving the l2-norm of the image. Default=False.
- n_iterint, optional
Number of iterations of the recursive neighbor agglomeration. Default=10.
- thresholdfloat in the open interval (0., 1.), optional
Threshold used to handle eccentricities. Default=1e-7.
- 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_levelinteger, optional
Rough estimator of the amount of memory used by caching. Higher value means more memory for caching. Default=1.
- verboseint, optional
Verbosity level. Default=0.
References
- 1
A. Hoyos-Idrobo, G. Varoquaux, J. Kahn and B. Thirion, “Recursive Nearest Agglomeration (ReNA): Fast Clustering for Approximation of Structured Signals,” in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 41, no. 3, pp. 669-681, 1 March 2019. https://hal.archives-ouvertes.fr/hal-01366651/
- Attributes
- `labels_ `ndarray, shape = [n_features]
Cluster labels for each feature.
- `n_clusters_`int
Number of clusters.
- `sizes_`ndarray, shape = [n_features]
It contains the size of each cluster.
__init__
(mask_img, n_clusters=2, scaling=False, n_iter=10, threshold=1e-07, memory=None, memory_level=1, verbose=0)¶Initialize self. See help(type(self)) for accurate signature.
fit
(X, y=None)¶Compute clustering of the data.
- Parameters
- Xndarray, shape = [n_samples, n_features]
Training data.
- yIgnored
- Returns
- selfReNA object
transform
(X, y=None)¶Apply clustering, reduce the dimensionality of the data.
- Parameters
- Xndarray, shape = [n_samples, n_features]
Data to transform with the fitted clustering.
- Returns
- X_redndarray, shape = [n_samples, n_clusters]
Data reduced with agglomerated signal for each cluster.
inverse_transform
(X_red)¶Send the reduced 2D data matrix back to the original feature space (voxels).
- Parameters
- X_redndarray , shape = [n_samples, n_clusters]
Data reduced with agglomerated signal for each cluster.
- Returns
- X_invndarray, shape = [n_samples, n_features]
Data reduced expanded to the original feature space.
fit_predict
(X, y=None)¶Perform clustering on X and returns cluster labels.
- Parameters
- Xarray-like of shape (n_samples, n_features)
Input data.
- yIgnored
Not used, present for API consistency by convention.
- Returns
- labelsndarray of shape (n_samples,), dtype=np.int64
Cluster labels.
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.