mvtsa: segmentation, warping and clustering of multivariate time series#

mvtsa

mvtsa cuts multivariate time series into homogeneous segments, compares series whose time axes do not agree, and groups them. It implements the segmentation and warping methods developed at the University of Pannonia — PCA and dynamic-PCA segmentation, modified Gath–Geva fuzzy segmentation, recursive-PCA on-line segmentation, Fisher-information segmentation, correlation-based dynamic time warping, mixed piecewise-linear measures and episode alignment — next to the strongest methods of the field and several new ones, with tools to evaluate, validate, explain, simplify and operate the resulting models.

Segmentation

Costs (L2, Gaussian, linear, AR, kernel, PCA T²/Q, regression) × searches (bottom-up with merge hierarchy, top-down, optimal, PELT, window, SWAB); latent-variable, fuzzy and Fisher segmentation; BOCPD, HMM, ClaSP, FLUSS, state, predictive and consensus segmenters.

Segmentation
Warping

DTW with constraints, step patterns and lower bounds; derivative, weighted, amerced and shape DTW; LCSS, EDR, ERP, TWED, MSM; soft-DTW, GAK, SBD; correlation-based DTW, MPLA/SPLA/MDPLA and episode alignment.

Warping and elastic similarity
Clustering

k-means with DBA and soft-DTW centres, k-Shape, k-medoids, fuzzy c-medoids, hierarchical, spectral, density-based and consensus clustering; segment and trajectory clustering.

Clustering
Representations

PCA, PPCA, recursive and dynamic PCA, similarity factors, SPD geometry; PAA, APCA, PLA, PIP, SAX, ABBA, SFA; episodes; features and path signatures; visibility and recurrence networks; matrix profiles.

Representations
Evaluation

F1, covering, Hausdorff; ARI/AMI; retrieval curves; stability and sensitivity; Friedman–Nemenyi and Wilcoxon–Holm tests; benchmarks and grid search.

Evaluation and validation
Model operations

Configurations as code, analysis pipelines, model files with checksums, a registry with stages, experiment tracking, data contracts, drift monitoring and model cards.

Model operations
Gallery

Forty-eight runnable examples on synthetic data, simulated chemical processes and UEA & UCR collections; each ends with a parameter study.

Example gallery
Method lineage

Where every method comes from, with the original publications.

Method lineage
The book

Segmentation, Warping and Clustering of Multivariate Time Series in Python: methods, algorithms and every example of the gallery.

The book

Quick start#

import mvtsa as mv

X, cps, _ = mv.datasets.make_correlation_switching(n_segments=4, length=150)
seg = mv.segment(X, "pca", n_segments=4, n_components=1)     # PCA Q-statistic, bottom-up
mv.viz.plot_segmentation(X, seg, truth=cps)

C, y = mv.datasets.make_signatures(n_writers=6, n_per_writer=8)
D = mv.warping.CBDTW(n_segments=10, n_components=2).fit(C).pairwise()   # correlation-based DTW
labels = mv.clustering.KMedoids(6, metric="precomputed").fit(D).labels_