Subsequence Matching in Data Streams

Machiko Toyoda, Yasushi SakuraiNTT 2013

Abstract

Subsequence matching is a fundamental task in data stream mining. While Dynamic Time Warping (DTW) is a robust similarity measure, its computational intensity often precludes real-time application. This paper presents SPRING and CrossMatch, two high-performance algorithms that enable efficient, one-pass DTW-based matching for query-to-stream and stream-to-stream scenarios, respectively.

Introduction

In modern data-driven environments—ranging from financial markets to industrial sensor networks—information arrives as continuous, high-velocity streams. A critical requirement in these domains is the ability to detect specific patterns or "subsequences" that match a known template or correlate with another live stream. Dynamic Time Warping (DTW) is the preferred metric for this task because it can handle non-linear temporal distortions (warping), where patterns may occur at varying speeds. However, the $O(nm)$ complexity of standard DTW makes it prohibitively expensive for infinite streams.

The Challenge of Streaming DTW

A naive approach to finding a query of length $m$ in a stream of length $n$ would involve re-calculating the DTW distance at every possible starting point, leading to an $O(n^2)$ complexity. To be viable for real-time monitoring, an algorithm must process each incoming data point in constant time and space relative to the stream's history.

Dynamic Time Warping (DTW) aligns two sequences by accounting for temporal shifts.

SPRING: Efficient Query-to-Stream Matching

The SPRING algorithm addresses the query-to-stream problem where a fixed query $Y$ is searched for within an evolving stream $X$. It achieves $O(m)$ time complexity per time-tick through two primary innovations:

  1. Star-padding: By prefixing the query with a special "don't care" symbol ($*$) that has zero distance to any stream value, SPRING treats the entire stream as a single alignment problem. This effectively allows a match to begin at any time-tick without restarting the calculation.
  2. Subsequence Time Warping Matrix (STWM): SPRING maintains a matrix that tracks the cumulative distance and the starting index of the current best candidate match. When the distance at the end of the query falls below a threshold $\epsilon$, a match is reported.
The SPRING algorithm identifies the exact boundaries of matching subsequences in a noisy data stream.

CrossMatch: Stream-to-Stream Correlation

CrossMatch extends these concepts to the stream-to-stream scenario, identifying similar patterns between two co-evolving data sources. It utilizes a scoring function inspired by local alignment techniques in bioinformatics. By rewarding similarity and penalizing distance, the algorithm can "prune" candidate matches that become too dissimilar, resetting their scores to zero. This mechanism ensures the algorithm only tracks relevant potential matches, maintaining constant space complexity.

Key Results and Applications

The algorithms were evaluated using real-world sensor data, such as temperature and humidity monitoring.

  • Efficiency: SPRING processes each tick in $O(m)$ time, while CrossMatch operates in $O(w)$ time (where $w$ is the warping window).
  • Accuracy: Both methods are mathematically guaranteed to produce the same results as an exhaustive brute-force search, ensuring no "false dismissals."
  • Practicality: In a 30,000-tick temperature stream, SPRING successfully isolated specific fluctuations, demonstrating its robustness against noise and its ability to handle long-duration deployments on standard hardware.

Conclusion

SPRING and CrossMatch represent a significant advancement in stream mining, bringing the power of DTW to real-time applications. By reducing the computational burden to constant time per update without sacrificing accuracy, these algorithms provide a scalable solution for pattern discovery in infinite data streams. Future work will focus on extending these techniques to high-dimensional multivariate data and automating threshold selection.

Summary updated

BibTeX
@inproceedings{toyoda2013subsequence,
  author = {Machiko Toyoda and Yasushi Sakurai},
  title = {{Subsequence Matching in Data Streams}},
  booktitle = {NTT},
  year = {2013},
  doi = {10.53829/ntr201301ra1},
}
Figure