Learning Representations for Time Series Clustering

Qianli Ma, Jiawei Zheng, Sen Li, Gary W. Cottrell

Clustering time series data is a notoriously difficult task. Unlike static data, time series are high-dimensional, noisy, and their defining patterns often occur across multiple scales (e.g., a daily trend versus a monthly cycle). Traditionally, researchers had to choose between manual feature engineering—which requires deep domain expertise—or raw-data methods that are easily tripped up by outliers.

In their NeurIPS 2019 paper, Ma et al. introduce Deep Temporal Clustering Representation (DTCR), a model that learns how to represent time series specifically for the purpose of clustering, without needing any human-labeled data.

TL;DR

DTCR is an unsupervised framework that integrates a sequence-to-sequence (seq2seq) reconstruction task with a K-means objective to learn cluster-friendly representations of time series. By combining multi-scale dilated RNNs with a clever "fake-sample" detection task, the model achieves state-of-the-art performance across 36 benchmark datasets.

What Problem Does This Paper Address?

The core challenge in unsupervised time series clustering is finding a "latent representation"—a compressed version of the data—that preserves the important temporal dynamics while making different groups easy to separate.

Existing deep learning approaches often use an autoencoder to compress the data. However, a standard autoencoder only cares about reconstruction (how well it can recreate the input). It doesn't necessarily care about clustering (how well these points group together). Furthermore, encoders can sometimes "cheat" by memorizing noise rather than learning the underlying temporal logic. DTCR aims to bridge this gap by forcing the model to learn features that are simultaneously reconstructible, clusterable, and temporally "real."

Methods

The DTCR architecture is built on three main pillars:

DTCR Architecture
  1. The Seq2Seq Backbone: The model uses an encoder-decoder structure. The encoder is a bidirectional Dilated Recurrent Neural Network (RNN). Dilated connections allow the network to "skip" time steps, helping it capture patterns at different scales (short-term vs. long-term) without the computational burden of massive hidden states.
  2. The K-means Objective: Instead of running K-means as a post-processing step, DTCR integrates it directly into the loss function. They use a "spectral relaxation" of the K-means objective, which essentially guides the latent space to form distinct, tight clusters during the training process itself.
  3. The Fake-Sample Task: To prevent the encoder from becoming "lazy," the authors introduce an auxiliary classification task. They generate "fake" time series by randomly shuffling segments of the original data. The encoder must then classify whether a sample is "real" or "fake." This forces the model to learn the actual temporal order and dynamics of the data to succeed.

The final loss function is a weighted sum of these three components: Reconstruction + K-means + Classification.

Datasets

The authors evaluated DTCR on a massive scale:

  • 36 UCR Time Series Datasets: This is the gold standard benchmark for the field, covering everything from ECG readings to sensor data from Ford engines.
  • StarLightCurves: A significantly larger and more complex dataset containing 9,236 samples, each with a length of 1,024, used to test the model's scalability and performance on high-dimensional data.

Key Insights and Ideas

  • Joint Optimization is Key: The paper demonstrates that learning the representation while optimizing for clustering leads to much better "cluster-specific" features than doing them sequentially.
  • The Power of Dilation: Using dilated RNNs is a game-changer for time series. It allows the model to have a much larger "receptive field," meaning it can see the "big picture" of a long sequence more effectively than a standard RNN.
  • Robustness Through Reconstruction: One of the most interesting findings is that the reconstruction loss acts as a stabilizer. Even if the K-means objective initially makes a mistake (grouping two different things together), the need to reconstruct the original, distinct signals eventually "pulls" the representations apart, correcting the error.
  • Data Augmentation via Shuffling: The "fake-sample" strategy is a simple but highly effective way to perform self-supervised learning, ensuring the encoder captures meaningful temporal dependencies.
Ablation Study: Impact of K-means and Classification Loss

As shown in the ablation study visualizations above, removing either the K-means loss or the classification loss results in significantly messier, overlapping clusters. The full DTCR model is required to achieve clean separation.

Key Results

DTCR outperformed 11 representative time series clustering methods (including k-Shape and various deep learning models like DEC and IDEC) and 2 state-of-the-art non-time-series deep clustering methods.

  • Average Rank: Across 36 datasets, DTCR achieved the lowest average rank (3.0694) compared to all other methods.
  • Rand Index (RI): DTCR achieved the highest average RI (0.7714), indicating its clusters were most consistent with the true (hidden) labels.
  • StarLightCurves: On this complex dataset, DTCR achieved a Normalized Mutual Information (NMI) score of 0.6731, significantly beating the previous state-of-the-art (DTC) which scored 0.6072.

Limitations and Future Work

While DTCR is powerful, the authors note a few areas for growth:

  • Missing Values: The current framework assumes complete time series. In many real-world scenarios (like medical sensors), data is often missing. Extending DTCR to handle "gappy" data is a primary goal for future work.
  • Hyperparameter Sensitivity: Like many deep learning models, DTCR relies on several hyperparameters (like the weight of the K-means loss). While the paper provides some guidance, finding the optimal balance for a brand-new dataset might require significant tuning.
  • Computational Complexity: While more efficient than some methods, the iterative SVD (Singular Value Decomposition) required for the K-means objective can be computationally expensive as the number of samples grows very large.

Summary updated

BibTeX
@inproceedings{ma2019learning,
  author = {Qianli Ma and Jiawei Zheng and Sen Li and Gary W. Cottrell},
  title = {{Learning Representations for Time Series Clustering}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2019},
}
Figure