thedatumorg/kshape-python

Python implementation of k-Shape

What it solves

Time series data appears in many fields—from sensors to finance—and grouping similar series is a common need. k-Shape provides an unsupervised way to cluster such data without labels, and it does so with high accuracy and efficiency, even as dataset sizes grow.

How it works

The algorithm iteratively assigns each time series to the cluster whose shape is most similar, then updates each cluster’s representative shape (centroid) based on the assigned members. It uses a shape-based distance measure and a specialized centroid computation that keeps the method fast. The code includes two implementations: one for CPU (parallelised) and one for GPU (using PyTorch), so you can choose based on your hardware.

Who it’s for

Researchers and practitioners who need to group time-series data—for example in computer science, engineering, biology, finance, or space science. The README notes adoption by Fortune 500 companies and the European Space Agency. It also provides preprocessed benchmark datasets (UCR univariate, UAE multivariate) to reproduce results.

Highlights

  • Selected as a best paper at ACM SIGMOD 2015 and received the inaugural Research Highlight Award.
  • Supports both univariate and multivariate time-series clustering.
  • Provides CPU and GPU implementations (via PyTorch).
  • Includes detailed performance benchmarks on 128 univariate and 28 multivariate datasets, with accuracy metrics (RI, ARI, NMI) and runtimes.

Related

  • Project
  • Project
  • Project
  • Project