TimeSeriesKMeansTslearn
K-means clustering for time-series data, from tslearn.
Quickstart
from sktime.clustering.k_means import TimeSeriesKMeansTslearn
estimator = TimeSeriesKMeansTslearn(n_clusters=3, max_iter=50, tol=1e-06, n_init=1, metric='euclidean', max_iter_barycenter=100, metric_params=None, n_jobs=None, dtw_inertia=False, verbose=0, random_state=None, init='random')Parameters(12)
- n_clustersint (default: 3)
- Number of clusters to form.
- max_iterint (default: 50)
- Maximum number of iterations of the k-means algorithm for a single run.
- tolfloat (default: 1e-6)
- Inertia variation threshold. If at some point, inertia varies less than this threshold between two consecutive iterations, the model is considered to have converged and the algorithm stops.
- n_initint (default: 1)
- Number of time the k-means algorithm will be run with different centroid seeds. The final results will be the best output of n_init consecutive runs in terms of inertia.
- metric{“euclidean”, “dtw”, “softdtw”} (default: “euclidean”)
- Metric to be used for both cluster assignment and barycenter computation. If “dtw”, DBA is used for barycenter computation.
- max_iter_barycenterint (default: 100)
Number of iterations for the barycenter computation process. Only used if
metric="dtw"ormetric="softdtw".- metric_paramsdict or None (default: None)
Parameter values for the chosen metric. For metrics that accept parallelization of the cross-distance matrix computations,
n_jobskey passed inmetric_paramsis overridden by then_jobsargument.- n_jobsint or None, optional (default=None)
The number of jobs to run in parallel for cross-distance matrix computations. Ignored if the cross-distance matrix cannot be computed using parallelization.
Nonemeans 1 unless in ajoblib.parallel_backendcontext.-1means using all processors. See scikit-learns’ Glossary for more details.- dtw_inertia: bool (default: False)
- Whether to compute DTW inertia even if DTW is not the chosen metric.
- verboseint (default: 0)
- If nonzero, print information about the inertia while learning the model and joblib progress messages are printed.
- random_stateinteger or numpy.RandomState, optional
- Generator used to initialize the centers. If an integer is given, it fixes the seed. Defaults to the global numpy random number generator.
- init{‘k-means++’, ‘random’ or an ndarray} (default: ‘random’)
Method for initialization: ‘k-means++’: use k-means++ heuristic. See scikit-learn’s k_init_ for more. ‘random’: choose k observations (rows) at random from data for the initial centroids. If an ndarray is passed, it should be of shape (n_clusters, ts_size, d) and gives the initial centers.