On Prediction Using Variable Order Markov Models

Ron Begleiter, Ran El-Yaniv, Golan Yona

Abstract

Variable Order Markov Models (VMMs) are a powerful class of algorithms for modeling discrete sequences by dynamically adjusting context lengths to balance model complexity and data sparsity. This paper presents a comparative empirical study of six prominent VMM algorithms—LZ78, PPM, CTW, DE-CTW, PST, and LZ-MS—across three distinct domains: English text, polyphonic music, and protein sequences. Our results demonstrate a significant performance gap between sequence prediction and classification tasks. While DE-CTW and PPM provide superior compression (log-loss) for text and music, the LZ-MS variant excels in protein classification, suggesting that the structural properties required for optimal prediction differ from those required for effective classification.

Introduction

Predicting the next symbol in a discrete sequence is a foundational task in machine learning, with applications ranging from lossless compression to bioinformatics. While standard $N$-gram Markov models are simple to implement, they face a fundamental trade-off: small $N$ values fail to capture long-range dependencies, while large $N$ values lead to severe data sparsity, often referred to as the "zero-frequency problem."

Variable Order Markov Models (VMMs) address this by dynamically adjusting the context length based on the available training data. Despite their utility, the field has lacked a unified comparison of these algorithms across different data types. This study fills that gap by evaluating how these models handle the varying complexities of English text, polyphonic music, and biological sequences.

Methods

We evaluate six distinct VMM approaches that represent the state-of-the-art in sequence modeling:

  1. LZ78: The classic Lempel-Ziv incremental parsing algorithm.
  2. PPM (Prediction by Partial Match): A high-performance compression algorithm that uses "escape" symbols to drop to lower-order contexts when a symbol is novel in the current context.
  3. CTW (Context Tree Weighting): A Bayesian approach that mixes predictions from all possible tree-structured models up to a maximum depth.
  4. DE-CTW (Decomposed CTW): A variant of CTW designed for large alphabets; it decomposes multi-symbol prediction into a hierarchy of binary decisions.
  5. PST (Probabilistic Suffix Trees): A popular machine learning approach that learns a single "best" suffix tree based on statistical significance.
  6. LZ-MS: A modern variant of LZ78 that utilizes "input shifting" and "back-shift parsing" to extract more statistics and maintain better context between parsed phrases.
The phrase tree constructed by the LZ78 algorithm for the sequence "abracadabra." Each node tracks symbol counts to estimate conditional probabilities.

Experimental Setup

The models were benchmarked on three diverse datasets:

  • English Text: The Calgary Corpus, containing 18 files including literature, source code, and technical papers.
  • Music: 285 MIDI files spanning classical, jazz, and rock/pop, where each channel was treated as a sequence of pitch:volume:duration triples.
  • Proteins: Sequences from the SCOP (Structural Classification of Proteins) database, involving a classification task across 765 different structural categories (folds).

Key Results and Discussion

Prediction vs. Classification

The most striking finding of this study is that the best algorithm for prediction is not necessarily the best for classification. LZ-MS, which showed mediocre performance in raw prediction (compression), emerged as the undisputed champion in protein classification. It achieved an average error rate of 0.14 (86% accuracy), significantly outperforming the runner-up, DE-CTW (0.18). This suggests that for classification, capturing rare but highly specific long-range patterns is more critical than maintaining a well-calibrated probability distribution for every symbol.

Performance in Text and Music

For sequence prediction tasks, DE-CTW was the overall winner. In the text domain, it achieved an average log-loss of 3.02 bits/symbol, narrowly beating PPM-C (3.03). In music, DE-CTW led with 1.21 bits/symbol. The success of DE-CTW highlights the importance of alphabet decomposition when dealing with the large alphabets found in text and complex musical triples.

Protein Incompressibility

Interestingly, VMMs often struggled to outperform a simple zero-order "background" distribution when predicting protein sequences. This aligns with biological theories suggesting that proteins are composed of distinct functional domains with unique distributions rather than being globally repetitive, making them difficult to compress using standard Markovian assumptions.

Conclusion

Our empirical evaluation reveals a "no free lunch" scenario in sequence modeling. While Bayesian mixing methods like DE-CTW and escape-based methods like PPM dominate in prediction and compression, parsing-based methods like LZ-MS are more robust for classification tasks. Future research should focus on developing specialized VMMs designed specifically for classification and exploring adaptive weight learning to further optimize context mixtures.

Summary updated

BibTeX
@article{begleiter2004prediction,
  author = {Ron Begleiter and Ran El-Yaniv and Golan Yona},
  title = {{On Prediction Using Variable Order Markov Models}},
  journal = {J. Artif. Intell. Res.},
  year = {2004},
  doi = {10.1613/jair.1491},
}
Figure