IterativeVotingClustering¶
- class tsml_eval.estimators.clustering.consensus.IterativeVotingClustering(clusterers=None, init='plus', n_clusters=8, max_iterations=500, random_state=None)[source]¶
IVC (Iterative Voting Clustering) Consensus Clusterer.
IVC is a consensus clustering algorithm that combines the results of multiple base clusterers to find a consensus clustering. It iteratively refines cluster assignments based on a majority voting scheme.
- Parameters:
- clustererslist of clusterers, default=None
A list of clusterers to use in the ensemble. If None, defaults to 5 KMeans clusterers.
- init{‘plus’, ‘random’, ‘aligned’}, default=’plus’
The method used to initialize the cluster centers. ‘plus’ uses the k-means++ initialization method, ‘random’ uses random selection, and ‘aligned’ uses a method that aligns the cluster assignmeds from the base clusterers.
- n_clustersint, default=8
The number of clusters to form.
- max_iterationsint, default=500
The maximum number of iterations to perform.
- random_stateint, default=None
The seed for random number generation.
Examples
>>> from tsml_eval.estimators.clustering.consensus.ivc import ( ... IterativeVotingClustering ... ) >>> from sklearn.datasets import load_iris >>> from sklearn.metrics import rand_score >>> iris = load_iris() >>> ivc = IterativeVotingClustering(n_clusters=3, random_state=0) >>> ivc.fit(iris.data) IterativeVotingClustering(...) >>> rand_score(iris.target, ivc.labels_) 0.8737360178970918
- Attributes:
- labels_ndarray of shape (n_instances,)
Labels of each point from the last fit.
Methods
fit(X[, y])Fit model to X using IVC.
fit_predict(X[, y])Perform clustering on X and returns cluster labels.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
predict(X)Predict cluster labels for X.
set_params(**params)Set the parameters of this estimator.
- fit_predict(X, y=None, **kwargs)[source]¶
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.
- **kwargsdict
Arguments to be passed to
fit.Added in version 1.4.
- Returns:
- labelsndarray of shape (n_samples,), dtype=np.int64
Cluster labels.
- get_metadata_routing()[source]¶
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)[source]¶
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)[source]¶
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.