pyriemann.clustering.MeanShift¶
- class pyriemann.clustering.MeanShift(kernel='uniform', bandwidth=None, metric='riemann', tol=0.001, max_iter=100, n_jobs=1)¶
Clustering by mean shift with SPD/HPD matrices as inputs.
The mean shift is a non-parametric clustering method used to find clusters on the manifold of SPD/HPD matrices, estimating the gradient of matrices density [1].
- Parameters:
- kernel{“normal”, “uniform”} | callable, default=”uniform”
Kernel used for kernel density estimation.
- bandwidthNone | float, default=None
Bandwidth of the kernel.
- metricstring | dict, default=”riemann”
Metric used for map estimation (for the list of supported metrics, see
pyriemann.utils.tangentspace.log_map()) and for distance estimation (seepyriemann.utils.distance.distance()). The metric can be a dict with two keys, “map” and “distance” in order to pass different metrics.- tolfloat, default=1e-4
Stopping criterion to stop convergence, representing the norm of gradient.
- max_iterint, default=100
Maximum number of iteration to reach convergence.
- n_jobsint, default=1
Number of jobs to use for the computation. This works by computing each of the n_init runs in parallel. If -1 all CPUs are used. If 1 is given, no parallel computing code is used at all, which is useful for debugging. For n_jobs below -1, (n_cpus + 1 + n_jobs) are used. Thus for n_jobs = -2, all CPUs but one are used.
- Attributes:
- modes_ndarray, shape (n_modes, n_channels, n_channels)
Modes of each cluster.
- labels_ndarray, shape (n_matrices,)
Labels, ie mode indices, of each matrix of training set.
See also
Notes
Added in version 0.9.
References
[1]Nonlinear Mean Shift over Riemannian Manifolds R. Subbarao & P. Meer. International Journal of Computer Vision, 84, 1-20, 2009
- __init__(kernel='uniform', bandwidth=None, metric='riemann', tol=0.001, max_iter=100, n_jobs=1)¶
Init.
- fit(X, y=None)¶
Fit the modes of clusters.
- Parameters:
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD/HPD matrices.
- yNone
Not used, here for compatibility with sklearn API.
- Returns:
- selfMeanShift instance
The MeanShift instance.
- fit_predict(X, y=None)¶
Fit and predict in a single function.
- Parameters:
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD matrices.
- yNone
Not used, here for compatibility with sklearn API.
- Returns:
- predndarray of int, shape (n_matrices,)
Prediction for each matrix according to the closest cluster.
- 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.
- predict(X)¶
Get the predictions.
- Parameters:
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD/HPD matrices.
- Returns:
- predndarray of int, shape (n_matrices,)
Prediction for each matrix according to the closest mode.
- 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.