tsseg: time series segmentation in Python#
Time series segmentation in Python
Change point detection and state detection: 30+ algorithms behind one scikit-learn-style API, with the metrics to evaluate them.
pip install tsseg
Two questions about one series
tsseg gathers classic and recent algorithms for time series segmentation behind a single API. It covers the two faces of the problem.
Where does the behaviour change?
- Output
- the sorted indices where a new segment starts
- Example
[580, 1125, 2050, 2465, 3995]
Which recurring state is each point in?
- Output
- one integer label per time point
- Example
[0, 0, …, 2, 2, …, 1, 1, …, 0, 0, …]
Ready for your own series
One API for every method
Each detector is a scikit-learn estimator that follows the segmenter interface of
aeon: fit, predict,
fit_predict, get_params, clone.
Unsupervised or guided
Run a detector without knowing how many segments to expect, or pass the number of change points or states to its constructor when you know it. Tags tell which modes each detector supports.
Benchmarked
TSB-SEG (NeurIPS 2026) evaluates 26 tsseg detectors on 592 series from 8 datasets, for both tasks, and publishes every run: pick a method from measured results.
Segment a recording in a few lines
Segment a motion-capture recording bundled with tsseg, then score both results against its ground truth.
- Install tsseg; the state detector of this example needs
pip install "tsseg[accelerators,aeon]". - Load a series: a NumPy array of shape
(n_timepoints, n_channels), a pandas Series or DataFrame. - Fit and predict with any detector, then score the result.
from tsseg import load_mocap
from tsseg.algorithms import BottomUpDetector, ClapDetector
from tsseg.algorithms.utils import extract_cps
from tsseg.metrics import Covering, StateMatchingScore
# 4 channels (arms and legs), one activity label per time point
X, y = load_mocap(trial=0) # X: (4579, 4), y: (4579,)
true_cps = extract_cps(y) # [ 588 1200 2006 2530 3282 4048]
# Change point detection: where does the movement change?
cps = BottomUpDetector(model="rbf", pen_scale="bic").fit_predict(X)
print(cps) # [ 580 1125 2050 2465 3995]
print(Covering().compute(true_cps, cps, n_timepoints=len(X))["score"]) # 0.748
# State detection: which activity is each time point in?
states = ClapDetector().fit_predict(X)
print(StateMatchingScore().compute(y, states)["score"]) # 0.700
# Know how many segments to expect? Pass it to the constructor (guided mode)
from tsseg.algorithms import DynpDetector
print(DynpDetector(model="rbf", n_cps=6).fit_predict(X))
# [ 595 1145 2160 2455 3300 4115]
Eight worked examples on public data
From the narrative voice of a Victorian novel to a night of sleep recordings: each example asks a question about a real record, answers it with one detector and checks the result against a reference the detector never sees.
An interactive map of the methods
Every detector placed by how it searches for a segmentation and by what makes a segment homogeneous. Filter by task, mode or install, search by name or idea, and open any method in one click.
Try it in the browser
The tsseg demo on Hugging Face Spaces loads a series, runs segmentation algorithms, then compares and evaluates their results, with nothing to install.
Published at ECML-PKDD 2026
tsseg: An Interactive Toolkit for Time Series Segmentation
Félix Chavelli, Arik Ermshaus, Fan Yang, Patrick Schäfer, John Paparrizos, Paul Boniol
doi:10.1007/978-3-032-37685-5_41Please also cite:
- TSB-SEG (NeurIPS 2026), if you compare segmentation methods or use its results;
- Toward Interpretable Evaluation Measures for Time Series Segmentation (NeurIPS 2025), if you use WARI, WNMI or SMS;
- the original paper of each detector, given on its page.
BibTeX entries for all three are in the README and in CITATION.cff.
@inproceedings{tsseg2026,
title = {tsseg: An Interactive Toolkit for Time Series Segmentation},
author = {Chavelli, F{\'e}lix and Ermshaus, Arik and Yang, Fan and
Sch{\"a}fer, Patrick and Paparrizos, John and Boniol, Paul},
booktitle = {Machine Learning and Knowledge Discovery in Databases.
Applied Data Science Track, Demo Track and Industrial Track},
series = {Lecture Notes in Computer Science},
year = {2026},
pages = {391--394},
publisher = {Springer Nature Switzerland},
doi = {10.1007/978-3-032-37685-5_41}
}
Contributors
Contributions are welcome: see the contributing guide. tsseg is released under the AGPL-3.0; several detectors bundle adapted or vendored code under their own licenses, listed in the README.