pyriemann.clustering.KmeansPerClassTransform¶
- class pyriemann.clustering.KmeansPerClassTransform(n_clusters=2, **params)¶
Clustering by k-means for each class with SPD/HPD matrices as inputs.
- Parameters:
- n_clustersint, default=2
Number of clusters.
- **paramsdict
The keyword arguments passed to
pyriemann.clustering.Kmeans.
- Attributes:
- classes_ndarray, shape (n_classes,)
Labels for each class.
- covmeans_ndarray, shape (n_centroids, n_channels, n_channels)
Centroids of each cluster of each class, with n_centroids <= n_clusters x n_classes.
See also
- __init__(n_clusters=2, **params)¶
Init.
- fit(X, y)¶
Fit the clusters for each class.
- Parameters:
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD/HPD matrices.
- yndarray, shape (n_matrices,)
Labels corresponding to each matrix.
- Returns:
- selfKmeansPerClassTransform instance
The KmeansPerClassTransform instance.
- fit_transform(X, y=None, sample_weight=None)¶
Fit and transform in a single function.
- Parameters:
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD matrices.
- yNone | ndarray, shape (n_matrices,), default=None
Labels for each matrix.
- sample_weightNone | ndarray, shape (n_matrices,), default=None
Weights for each matrix. If None, it uses equal weights.
- Returns:
- distndarray, shape (n_matrices, n_centroids)
Distance to each centroid.
- 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_output(*, transform=None)¶
Set output container.
See Introducing the set_output API for an example on how to use the API.
- Parameters:
- transform{“default”, “pandas”, “polars”}, default=None
Configure output of transform and fit_transform.
“default”: Default output format of a transformer
“pandas”: DataFrame output
“polars”: Polars output
None: Transform configuration is unchanged
Added in version 1.4: “polars” option was added.
- Returns:
- selfestimator instance
Estimator instance.
- 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.
- transform(X)¶
Get the distance to each centroid.
- Parameters:
- Xndarray, shape (n_matrices, n_channels, n_channels)
Set of SPD/HPD matrices.
- Returns:
- distndarray, shape (n_matrices, n_centroids)
Distance to each centroid according to the metric.