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.

7.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 [R1413c64648a2-1].

Parameters
mask_img: Niimg-like object used for masking the data.
n_clusters: int, optional (default 2)

The number of clusters to find.

scaling: bool, optional (default False)

If scaling is True, each cluster is scaled by the square root of its size, preserving the l2-norm of the image.

n_iter: int, optional (default 10)

Number of iterations of the recursive neighbor agglomeration

threshold: float in the open interval (0., 1.), optional (default 1e-7)

Threshold used to handle eccentricities.

memory: instance of joblib.Memory or string

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: integer, optional (default 1)

Rough estimator of the amount of memory used by caching. Higher value means more memory for caching.

verbose: int, optional (default 1)

Verbosity level.

References

R1413c64648a2-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__(self, 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(self, X, y=None)

Compute clustering of the data.

Parameters
X: ndarray, shape = [n_samples, n_features]

Training data.

y: Ignored
Returns
self: ReNA object
fit_predict(self, X, y=None)

Perform clustering on X and returns cluster labels.

Parameters
Xndarray, shape (n_samples, n_features)

Input data.

yIgnored

Not used, present for API consistency by convention.

Returns
labelsndarray, shape (n_samples,)

Cluster labels.

fit_transform(self, 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
Xnumpy array of shape [n_samples, n_features]

Training set.

ynumpy array of shape [n_samples]

Target values.

**fit_paramsdict

Additional fit parameters.

Returns
X_newnumpy array of shape [n_samples, n_features_new]

Transformed array.

get_params(self, 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
paramsmapping of string to any

Parameter names mapped to their values.

inverse_transform(self, X_red)

Send the reduced 2D data matrix back to the original feature space (voxels).

Parameters
X_red: ndarray , shape = [n_samples, n_clusters]

Data reduced with agglomerated signal for each cluster

Returns
X_inv: ndarray, shape = [n_samples, n_features]

Data reduced expanded to the original feature space

set_params(self, **params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). 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
selfobject

Estimator instance.

transform(self, X, y=None)

Apply clustering, reduce the dimensionality of the data.

Parameters
X: ndarray, shape = [n_samples, n_features]

Data to transform with the fitted clustering.

Returns
X_red: ndarray, shape = [n_samples, n_clusters]

Data reduced with agglomerated signal for each cluster