Hidden Markov Anomaly Detection

Nico Görnitz, Mikio L. Braun, Marius KloftICML 2015

Most classic anomaly detection algorithms, including the standard One-Class Support Vector Machine (OC-SVM), rely on the i.i.d. assumption: they assume data points are independent and identically distributed. However, in the real world, this is rarely true. Whether analyzing network traffic, speech, or DNA sequences, the "meaning" of a data point depends heavily on what came before and after it.

When you apply an i.i.d. model to sequential data, you lose the underlying "grammar" of the system. For example, a specific sensor reading might be perfectly normal in a "High Power" state but highly anomalous in an "Idle" state. Standard models struggle here because they only see the raw values, not the underlying state.

To bridge this gap, researchers have introduced Hidden Markov Anomaly Detection (HMAD), a novel framework that extends the popular OC-SVM to handle data with sequential dependencies. By incorporating a latent Markov structure, the model can detect anomalies in complex sequences far more accurately than methods treating data points as independent.

The HMAD Framework

The authors propose a kernel-based framework for Latent Anomaly Detection. The core innovation is the HMAD model, which operates on several key principles:

  1. Latent Variables: The model introduces a hidden state sequence ($z$) that explains the observed data ($x$). This is analogous to how a Hidden Markov Model (HMM) works, but it is framed as an optimization problem similar to an SVM.
Hidden Markov sequence structure
  1. Joint Feature Map: HMAD defines a feature map that captures both the "emissions" (the observed data at a specific state) and the "transitions" (the probability of moving from one state to another).
  2. Optimization via DC Programming: Because the resulting objective function is non-convex, the authors use a Difference of Convex functions (DC) algorithm. This iteratively solves the problem by alternating between finding the most likely hidden states (using the Viterbi algorithm) and updating the model parameters (solving a standard OC-SVM).
  3. The $\nu$ Parameter: Like the original OC-SVM, HMAD uses a parameter $\nu$ that allows the user to control the expected fraction of outliers in the dataset.

Datasets and Key Results

The researchers evaluated HMAD on three distinct types of data: controlled synthetic data, bioinformatics (prokaryotic gene finding in the E. coli genome), and computational sustainability (simulated wind turbine sensor data).

Across all domains, exploiting latent structure led to massive performance jumps:

  • Bioinformatics (Gene Finding): HMAD achieved a perfect AUC of 1.0, identifying every gene sequence with zero errors. In contrast, the best-performing standard OC-SVM only reached an AUC of 0.85.
  • Wind Turbines: HMAD achieved an AUC > 0.99 for detecting anomalous turbine states caused by specific weather conditions, significantly outperforming the regular OC-SVM (AUC 0.92).
  • Synthetic Benchmarks: In tests with Gaussian noise sequences, HMAD remained highly accurate even when anomalous sequences were highly fragmented. It consistently performed on par with the Bayes Classifier (the theoretical maximum possible performance), even as the fraction of anomalies in the training set increased up to 30%.
Detection accuracy vs percentage of anomalous data

Unlike supervised structured learning—which requires labeled sequences of "normal" versus "abnormal"—HMAD learns what "normal" looks like entirely from unlabeled data. This "one-class" advantage makes it highly practical for real-world security and monitoring tasks. Furthermore, the authors provided a large deviation bound on the generalization error, proving that the model's performance on training data is a reliable indicator of its performance on unseen data.

Limitations and Future Work

While highly effective, HMAD's reliance on the Viterbi algorithm means computational complexity grows with the number of possible hidden states and sequence length. Very long sequences with complex state spaces might require more optimized decoding.

Additionally, the current paper assumes the user knows the basic structure of the hidden states (e.g., a 2-state model). Automating the discovery of the number of latent states would be a valuable next step. Finally, the authors suggest this "latent anomaly detection" framework could be extended to more complex structures like trees or graphs, opening the door for analyzing social networks or chemical structures.

Summary updated

BibTeX
@inproceedings{gornitz2015hidden,
  author = {Nico Görnitz and Mikio L. Braun and Marius Kloft},
  title = {{Hidden Markov Anomaly Detection}},
  booktitle = {International Conference on Machine Learning},
  year = {2015},
  url = {https://openreview.net/forum?id=H1-PZ2W_-B},
}
Figure