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.

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

  • 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_`: intNumber 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:

X: ndarray, shape = [n_samples, n_features]

Training data.

y: Ignored

Returns:

self: ReNA object

fit_predict(X, y=None)

Perform clustering on X and returns cluster labels.

Parameters:

X : array-like of shape (n_samples, n_features)

Input data.

y : Ignored

Not used, present for API consistency by convention.

Returns:

labels : ndarray of shape (n_samples,)

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:

X : {array-like, sparse matrix, dataframe} of shape (n_samples, n_features)

Input samples.

y : ndarray of shape (n_samples,), default=None

Target values (None for unsupervised transformations).

**fit_params : dict

Additional fit parameters.

Returns:

X_new : ndarray array of shape (n_samples, n_features_new)

Transformed array.

get_params(deep=True)

Get parameters for this estimator.

Parameters:

deep : bool, default=True

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

Returns:

params : mapping of string to any

Parameter names mapped to their values.

inverse_transform(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(**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:

**params : dict

Estimator parameters.

Returns:

self : object

Estimator instance.

transform(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