skillfed

tslearn

A machine learning toolkit dedicated to time-series data

tslearn v0.9.0 313.5K downloads/30d#7,714 on PyPI3,168
Permissive license BSD-2-Clause Active released

What it is and what it does

tslearn is a machine learning toolkit built on top of scikit-learn, numpy, scipy, and numba that specializes in time series data. It provides clustering (TimeSeriesKMeans), classification (KNeighborsTimeSeriesClassifier), regression, and distance metrics including Dynamic Time Warping. The package expects time series as 3D numpy arrays and handles variable-length sequences.

The library integrates seamlessly with scikit-learn's ecosystem, supporting pipelines and hyperparameter tuning. It includes utilities for data preprocessing (scaling, resampling, piecewise transformations), dataset loading (UCR datasets), and analysis tasks like computing barycenters. Models follow scikit-learn's fit/predict API, making it accessible to developers already familiar with that framework.

Use it for:

  • Classify time series sequences using k-nearest neighbors with time-aware distance metrics
  • Cluster temporal data with TimeSeriesKMeans to find similar patterns across time series
  • Measure similarity between time series using Dynamic Time Warping or other specialized metrics
  • Preprocess variable-length time series with scaling and resampling before model training
  • Build scikit-learn pipelines combining time series preprocessing and classification steps

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

tslearn provides machine learning algorithms optimized for time series data, including clustering, classification, regression, and distance metrics like Dynamic Time Warping, built on scikit-learn's API.

Yes. tslearn is actively maintained, has no known vulnerabilities, uses permissive licensing, and offers low installation friction. It fills a clear gap for time series machine learning with scikit-learn compatibility. Install if you need specialized time series algorithms; skip if your use case fits standard scikit-learn or you require production-grade time series forecasting.

Install

tslearn on PyPI

pip

pip install tslearn

uv

uv add tslearn

poetry

poetry add tslearn

Installing tslearn

Before you install

Low friction: pure Python wheel with well-established dependencies (scikit-learn, numpy, scipy, numba, joblib, statsmodels). Active maintenance with last commit 2026-08-13 and release 43 days ago.

License in practice

BSD-2-Clause (permissive) allows commercial and private use with minimal restrictions; attribution required.

Quickstart

pip install tslearn
from tslearn.utils import to_time_series_dataset
from tslearn.neighbors import KNeighborsTimeSeriesClassifier
X = to_time_series_dataset([[1, 3, 4, 2], [1, 2, 4, 2]])
knn = KNeighborsTimeSeriesClassifier(n_neighbors=1)
knn.fit(X, [0, 1])

Requires Python >= 3.10

Verify before relying

  • Whether numba JIT compilation is required for acceptable performance on large datasets
  • Specific performance characteristics compared to alternative time series libraries

Package facts

License BSD-2-Clause (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 6 — scikit-learn, numpy, scipy, numba, joblib, statsmodels
Maintenance actively maintained — 43 days since the last release
Last repo commit
First released
Downloads 313,462/month — #7,714 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: tslearn-0.9.0-py3-none-any.whl

Intended Audience :: DevelopersIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Artificial IntelligenceTopic :: Software Development :: Libraries

Tags

time series machine learningtime series clustering classificationdynamic time warpingtime series distance metricstemporal data analysistime series k-meanstime series knn classifier
time-seriesscikit-learn-compatibledtw

More Libraries packages