Elastic Product Quantization for Time Series

Pieter Robberechts, Wannes Meert, Jesse Davis

Abstract

Similarity search in time series often relies on Dynamic Time Warping (DTW) to handle phase shifts, but DTW's computational cost limits its scalability. This paper introduces Elastic Product Quantization (PQDTW), which adapts product quantization for DTW by employing a wavelet-based pre-alignment strategy. By allowing segment boundaries to shift to "natural" breakpoints, PQDTW preserves local structures that rigid segmentation would otherwise destroy. Experimental results on 48 UCR datasets demonstrate up to a 225x speedup in clustering and significant memory savings with competitive accuracy.

The Problem with Rigid Segmentation

Similarity search is fundamental to time series data mining, used in domains ranging from cardiology to finance. While Euclidean distance is efficient, it is sensitive to temporal misalignments. Dynamic Time Warping (DTW) addresses this by finding an optimal non-linear alignment between sequences. However, DTW's $O(N^2)$ complexity makes it a bottleneck for large-scale datasets.

Product Quantization (PQ) is a popular technique for compressing high-dimensional vectors into short codes for fast Euclidean distance computation. However, applying PQ to DTW is non-trivial. Standard PQ divides a time series into fixed-length segments. If a critical feature, such as a peak, is split across two segments in one series but contained within a single segment in another, DTW cannot align them across the rigid segment boundaries. This "boundary constraint" leads to poor distance approximations.

Figure 1: Comparison of original time series, rigid segmentation, and segmentation after pre-alignment. Pre-alignment ensures that features like peaks are not split across boundaries, allowing for better DTW matching.

Methods: PQDTW

The authors propose PQDTW to overcome these limitations. The core innovation is a "pre-alignment" step that makes segmentation elastic. The method follows a modified PQ pipeline:

  1. Training Phase: Instead of standard k-means, they use DTW Barycenter Averaging (DBA) k-means to learn a codebook of representative sub-sequences (centroids).
  2. Pre-alignment via MODWT: Instead of cutting at fixed intervals, PQDTW uses the Maximal Overlap Discrete Wavelet Transform (MODWT) to identify natural breakpoints. By analyzing scaling coefficients, the algorithm finds points where the signal's local structure suggests a logical boundary.
  3. Fuzzy Segmentation: A "tail length" parameter allows the cut point to shift within a window to the nearest natural boundary identified by the wavelet. These variable-length segments are then re-interpolated to a fixed length to maintain compatibility with the codebook.
Figure 2: The MODWT-based segmentation process. The scaling coefficients (green) are used to identify natural segment points (dashed black lines) instead of using fixed-length points (dashed red line).

Key Results and Insights

PQDTW was evaluated on 48 datasets from the UCR Time Series Archive, covering sensor data, image outlines, and ECG recordings. The results highlight massive efficiency gains:

  • Speed: PQDTW achieves a 14x speedup for 1-NN classification and a staggering 225x speedup for hierarchical clustering compared to standard DTW.
  • Accuracy: It remains statistically competitive with Euclidean distance and significantly outperforms other compressed representations like SAX. While slightly less accurate than full, uncompressed DTW, the trade-off is negligible for the massive gains in scale.
  • Scalability: The method enables million-scale time series processing on commodity hardware by reducing memory footprints by factors of 26x to 2600x.

Conclusion

PQDTW successfully bridges the gap between the efficiency of product quantization and the robustness of elastic distance measures. By introducing wavelet-based pre-alignment, it solves the long-standing issue of boundary constraints in compressed time series search. While the initial encoding phase remains a bottleneck, the dramatic search speedups open the door for billion-scale time series retrieval systems.

Summary updated

BibTeX
@inproceedings{robberechts2022elastic,
  author = {Pieter Robberechts and Wannes Meert and Jesse Davis},
  title = {{Elastic Product Quantization for Time Series}},
  booktitle = {DS},
  year = {2022},
  doi = {10.1007/978-3-031-18840-4\_12},
}
Figure