tslearn-team/tslearn
The machine learning toolkit for time series analysis in Python
tslearn – Machine‑learning toolkit for time‑series in Python
What it is – A Python library that extends the familiar scikit‑learn API to work with time‑series data. It provides utilities for loading, preprocessing, and generating time‑series, plus a collection of algorithms for classification, clustering, regression, and similarity measurement.
Key capabilities
- Data handling – Convert lists, other toolkits, or UCR benchmark datasets into the required 3‑D NumPy array (
n_ts, max_len, dim). Supports variable‑length series. - Pre‑processing – Scaling, resampling, piece‑wise transforms, and synthetic generators.
- Algorithms
- Classification: K‑Nearest‑Neighbour, Support‑Vector Classifier, Learning Shapelets, Early Classification.
- Regression: K‑Nearest‑Neighbour Regressor, Support‑Vector Regressor, MLP.
- Clustering: TimeSeriesKMeans, K‑Shape, Kernel K‑Means.
- Metrics: Dynamic Time Warping, Global Alignment Kernel, matrix‑profile, barycenters.
- Full scikit‑learn compatibility – Models can be used inside pipelines, grid‑search, and other scikit‑learn utilities.
Installation
# PyPI (recommended)
python -m pip install tslearn
# Conda
conda install -c conda-forge tslearn
# From source
python -m pip install https://github.com/tslearn-team/tslearn/archive/main.zip
(Requires Python 3.10+ and the usual scientific‑Python stack.)
Typical workflow
- Load/format data →
to_time_series_datasetor one of the built‑in loaders. - Pre‑process with
TimeSeriesScalerMinMax, resampling, etc. - Fit a model, e.g.
KNeighborsTimeSeriesClassifier. - Predict / evaluate using the same scikit‑learn‑style methods.
- Optionally compute distances, barycenters, or other analyses.
Documentation & examples – Full API reference, user guide, and a gallery of Jupyter notebooks are hosted on Read the Docs: https://tslearn.readthedocs.io.
Community – Open‑source on GitHub, with contribution guidelines, an issue tracker for feature requests, and a citation ready for academic use (JMLR 2020).
Related
- Project
- Project
- Project
- Project
- Project