mvtsa: segmentation, warping and clustering of multivariate time series

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 by the group of János Abonyi at the
University of Pannonia over two decades — PCA and dynamic-PCA segmentation, the
modified Gath–Geva fuzzy segmentation, recursive-PCA on-line segmentation,
Fisher-information segmentation for experiment design, 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.
| Module |
Contents |
mvtsa.segmentation |
costs (L2, L1, Gaussian, linear, AR, kernel, PCA T²/Q, regression) × searches (bottom-up with a merge hierarchy, top-down, sliding window, SWAB, optimal partitioning, PELT, window discrepancy); PCA, dynamic-PCA, Krzanowski and recursive-PCA segmentation; modified Gath–Geva fuzzy segmentation; Fisher-information segmentation; BOCPD; sticky Gaussian HMM; sparse Gaussian states; ClaSP; FLUSS; segment-then-cluster states; predictive homogeneity with any scikit-learn model; consensus; streaming and CUSUM; selection of the number of segments |
mvtsa.warping |
DTW with windows, step patterns, penalties and lower bounds; DTW_I, DDTW, WDTW, ADTW, shapeDTW, FastDTW, subsequence DTW; LCSS, EDR, ERP, TWED, MSM; soft-DTW and its divergence, GAK, SBD; correlation-based DTW (static and dynamic PCA, Riemannian and mixed segment distances); MPLA/SPLA/MDPLA; episode alignment and episode DTW; DBA and soft-DTW barycenters; path statistics, tightness of warping, window learning, elastic ensemble |
mvtsa.clustering |
k-means (Euclidean, DBA, soft-DTW), k-Shape, k-medoids, fuzzy c-medoids, hierarchical, spectral, DBSCAN/HDBSCAN, consensus; feature- and signature-based, segment and trajectory clustering |
mvtsa.representation |
PCA, PPCA, recursive PCA, similarity factors (Krzanowski, λ, Eros), principal angles, SPD geometry; PAA, APCA, PLA, PIP, SAX, ABBA, SFA; triangular episodes; features and path signatures; visibility, six-sigma, ordinal and recurrence networks; recurrence plots, GAF, MTF; matrix and k-NN profiles |
mvtsa.evaluation |
F1 with margin, covering, Hausdorff, annotation error, state ARI/AMI; clustering scores, silhouette, Dunn, partition coefficient; k-NN accuracy, precision–recall curves, mAP; stability, sensitivity, Friedman–Nemenyi, Wilcoxon–Holm; benchmarks and grid search |
mvtsa.simplify, mvtsa.explain |
merging short segments, pruning, hierarchy reduction, PLA simplification, compression; variable contributions, segment tables, decision-tree rules of states, regime transition networks |
mvtsa.mlops |
JSON/YAML configurations, analysis pipelines, model files with checksums and data fingerprints, a model registry with stages, experiment tracking (local, optional MLflow), data contracts, drift monitoring, model cards; command line mvtsa |
mvtsa.viz |
segmented series, fuzzy memberships, segmentograms, cost curves, PCA statistics and loadings, alignments, cost matrices, alignment uncertainty, prototypes, dendrograms, Sammon and fuzzy Sammon maps, critical-difference diagrams, stability plots, dashboards |
mvtsa.datasets |
generators (piecewise stationary, correlation switching, dynamic switching, recurring regimes, energy, CBF, synthetic control, signatures, motion, correlation and dynamic sequences); pH and MMA polymerization reactor simulators; bundled BasicMotions, JapaneseVowels and GunPoint; UEA & UCR and TSSB fetchers |
Installation
pip install mvtsa # numpy, scipy, pandas, scikit-learn, matplotlib, networkx
pip install "mvtsa[fast]" # + numba for the dynamic-programming kernels
pip install "mvtsa[all]" # + MLflow, YAML, ruptures, stumpy
Quick start
import mvtsa as mv
# segmentation: four regimes that differ only in their correlation structure
X, cps, _ = mv.datasets.make_correlation_switching(n_segments=4, length=150)
seg = mv.segment(X, "pca", n_segments=4, n_components=1) # Q statistic, bottom-up
print(seg.change_points, cps) # [150 300 450] [150 300 450]
mv.viz.plot_segmentation(X, seg, truth=cps)
# warping: correlation-based DTW of on-line signatures
C, writer = mv.datasets.make_signatures(n_writers=6, n_per_writer=8)
D = mv.warping.CBDTW(n_segments=10, n_components=2).fit(C).pairwise()
print(mv.evaluation.knn_accuracy(D, writer))
# clustering on the same distances
labels = mv.clustering.KMedoids(6, metric="precomputed").fit(D).labels_
Documentation and book
Citing
J. Abonyi, mvtsa: segmentation, warping and clustering of multivariate time
series in Python, 2026. Zenodo, doi:10.5281/zenodo.24646850
(all versions; version 1.0 is doi:10.5281/zenodo.24646851) —
together with the original publications of the methods you use (see
CITATION.cff and the method lineage page of the documentation).
Acknowledgement
The research summarized in this package was supported by the National
Research, Development and Innovation Office of Hungary (NKFIH) through the
OTKA 143482 project. The package is maintained by the Complex Systems
Intelligence group (abonyilab.com) of the
University of Pannonia, Veszprém.
License
MIT (software); the book is published under CC BY 4.0.