Fast Algorithm for Monitoring Data Streams by Using Hidden Markov Models

Yasuhiro Fujiwara, Yasushi SakuraiNTT 2011

Abstract

Identifying the best-fitting Hidden Markov Model (HMM) for a continuous data stream is a critical task for applications such as traffic monitoring and anomaly detection. However, the computational cost of the standard Viterbi algorithm—$O(nm^2)$—often makes real-time processing impossible for large model sets. This paper introduces SPIRAL-Stream, an algorithm designed for efficient, exact HMM monitoring. By employing state clustering to generate likelihood upper bounds and leveraging temporal continuity, SPIRAL-Stream achieves speedups of up to 490x compared to traditional methods while guaranteeing the exactness of the results.

In modern data engineering, applications must handle continuous streams of input from external sources like sensors. When monitoring these streams, one must identify the model whose state sequences have the highest likelihood relative to the most recent data window. The primary bottleneck is the likelihood computation, which typically consumes 30-70% of total processing time in pattern recognition tasks. Naively running the Viterbi algorithm for every candidate model in a large library is computationally prohibitive.

The standard Viterbi trellis structure, where complexity scales quadratically with the number of states $m$.

SPIRAL-Stream Methodology

SPIRAL-Stream extends the previous SPIRAL method for static sequences to the streaming domain. It relies on three primary mechanisms to reduce search costs without sacrificing accuracy:

  1. Likelihood Approximation via State Clustering: Multiple states are merged into clusters to compute an approximate likelihood. Crucially, the likelihood of this simplified model serves as a guaranteed mathematical upper bound of the original model's likelihood.
  2. Multiple Granularities: The algorithm creates a hierarchy of models (e.g., scaling states by powers of two: $g = 1, 2, 4...$). It begins searching at the coarsest level; if a model's upper bound at this level is lower than the best likelihood found so far, the model is pruned immediately.
  3. Transition Pruning: Within a single model, paths in the trellis structure that cannot mathematically beat the current champion are discarded early.
The three core pruning strategies of SPIRAL-Stream: (a) Likelihood approximation, (b) Multiple granularities, and (c) Transition pruning.

Exploiting Temporal Continuity

A unique feature of SPIRAL-Stream is its use of "temporal continuity." In a data stream, the best-fitting model at time $t$ is highly likely to remain a strong candidate at time $t+1$. By testing the previous winner first, the algorithm establishes a high threshold early in the search process. This allows for the rapid pruning of most other candidate models at their coarsest, least expensive granularities.

Performance and Scalability

The algorithm was evaluated across four diverse datasets: EEG brainwave data, Chromosome DNA sequences, Traffic sensor data, and UNIX command histories. Results showed that SPIRAL-Stream is consistently faster than the naive Viterbi approach, reaching up to a 490x speedup in optimal cases. Furthermore, it outperformed the static SPIRAL algorithm by effectively utilizing the "best-so-far" model from previous time steps to accelerate the current search. Most "bad" models are eliminated at the 1-state or 2-state granularity, minimizing high-fidelity computation.

Conclusion

SPIRAL-Stream represents a significant advancement in data stream monitoring. It is the first method to address the HMM search problem in a way that guarantees exactness while providing the performance necessary for real-time applications. By intelligently clustering states and leveraging the inherent properties of streaming data, it removes the traditional "speed limit" of HMM-based pattern recognition.

Summary updated

BibTeX
@inproceedings{fujiwara2011fast,
  author = {Yasuhiro Fujiwara and Yasushi Sakurai},
  title = {{Fast Algorithm for Monitoring Data Streams by Using Hidden Markov Models}},
  booktitle = {NTT},
  year = {2011},
  doi = {10.53829/ntr201112ra2},
}
Figure