Hidden Markov Models in Modern Practice — Curriculum
Audience: a Python-first practitioner (finance-adjacent) who needs to know what Hidden Markov Models can still do in the 2020s, how to implement and train them correctly, where they are used in production today, and how to test an HMM-based idea honestly — especially in markets.
Status: curriculum architecture v1. Module IDs and file paths are stable. Module bodies are Draft v0.1 pending editorial and evidence review.
Contents
- Scope Contract
- Evidence Standard
- Learning Philosophy
- Canonical Order and Parts
- References Standard
- Suggested Study Paths
Scope Contract
This contract decides whether a topic, claim, library, or application belongs in this curriculum. It overrides module filenames and any legacy material.
Canonical scope
- The mechanics canon — forward, Viterbi, forward–backward, Baum–Welch (EM), scaling/log-space numerics, discrete and Gaussian (mixture) emissions, and the Markov-switching regression family (Hamilton filter). This is stable, prospectus-grade knowledge and is taught as fact.
- Verified tooling — Python libraries covered only with version and release dates verified against the library’s own release channel (PyPI, changelog, GitHub releases) at time of writing. A library’s maintenance status is part of the data: maintenance claims must cite the maintainer’s own words.
- Domain modern-practice surveys — bioinformatics, speech/audio, NLP, ecology/telemetry, finance. Each claim about a domain’s current status cites a primary source (project site, official docs, peer-reviewed paper, or institution publication) and carries a retrieval date. Domain verdicts use the fixed labels: thriving / legacy-but-alive / historical / hypothesis-under-test / unverified.
- Finance regime practice — HMM-based regime detection, routing, and sizing overlays evaluated as hypotheses under test. No module states or implies a proven trading edge.
Excluded or restricted
- No edge claims. Backtests shown without executable prices, transaction costs, and out-of-sample validation are presented only as motivation or as specimens of flawed methodology — never as results. The canonical adversarial comparisons (statistical jump models, threshold routers, changepoint methods) must be presented alongside, not afterthought.
- No unverified domains asserted as current practice. Epidemiology, cybersecurity, music alignment, and meteorology formulations exist but are listed as unverified until their own primary-source pass is done.
- No “HMM = modern SSM” conflation. S4/Mamba-style structured state-space models are deterministic linear recurrences trained by gradient descent, not probabilistic latent-variable models with posteriors and EM. They appear in Part I as context for what HMMs are not.
- No raw LaTeX math. All quantitative relationships follow the general rules: sentence → Python snippet with named variables → worked numeric example.
- Deprecated-API tutorials are out. Code must run against the verified library versions listed in Part II. pomegranate 0.x-style code is legacy context only.
Evidence Standard
- Hierarchy: original papers and official project/venue documents first; peer-reviewed or reproducible research second; practitioner education only as labeled background. Primary always outranks secondary.
- Date-stamping: every product, version, and domain-status fact carries URL + retrieval date (and effective/version date where applicable). Product facts expire operationally even when a URL stays live.
- No fabrication: any number or version that cannot be sourced is marked as an explicit placeholder the reader must replace, or the claim is cut.
- Contradictions are resolved in text, not hidden. The canonical example: descriptive HMM regime studies that “look good” versus out-of-sample, cost-inclusive comparisons where HMM routing loses to jump models. Both are presented; the mechanics-versus-edge gate resolves them.
- Mechanics vs edge gate: a source explaining how something works proves mechanics, never profitability or * superiority*. Superiority claims require out-of-sample, cost-inclusive evidence and are otherwise hypotheses.
Learning Philosophy
Every concept follows the general authoring flow: plain language first, diagram second, runnable code third, worked numbers fourth, pitfalls last. Modules favor the smallest implementation that produces a checkable number. Worked examples reuse one shared toy problem where possible (a 2-state weather HMM in Part I; a 2-state Gaussian HMM on a synthetic return series from Part III onward) so the reader sees one dataset evolve rather than meeting a new dataset every module.
Finance modules (15–18) additionally require a project card (see rules.md §5) before any strategy result is discussed.
Canonical Order and Parts
| Part | Title | Modules | Purpose |
|---|---|---|---|
| I | Foundations & the Inference Engine | 00–06 | Mechanics canon, from the three problems to honest model selection |
| II | Tooling & Evaluation | 07–10 | Verified library landscape and diagnostics |
| III | Modern Practice Across Domains | 11–14 | Primary-source domain surveys with verdicts |
| IV | Finance Regime Practice | 15–18 | Causal detection, costs, honest validation, gated capstone |
Part I — Foundations & the Inference Engine
| Module | File | Focus | Anchor sources |
|---|---|---|---|
| 00 | 00-orientation.md |
Why HMMs survived the deep-learning era; curriculum map; domain verdict preview | domain survey (2026-09 retrieval) |
| 01 | 01-hmm-three-problems.md |
The model; likelihood, decoding, learning; the three canonical problems | Rabiner 1989; Viterbi 1967; Baum et al. 1970 |
| 02 | 02-numerical-implementation.md |
Forward/backward/Viterbi from scratch; scaling and log-space; underflow | Rabiner 1989 §V |
| 03 | 03-gaussian-emissions-hamilton.md |
Gaussian and mixture emissions; regime-switching mean/vol; the Hamilton filter connection | Hamilton 1989; Zucchini et al. 2016 |
| 04 | 04-training-em-practice.md |
Baum–Welch in practice: initialization, restarts, convergence checks, label switching | Wu 1983; Balakrishnan et al. 2017 |
| 05 | 05-degenerate-solutions.md |
Covariance collapse, variance floors, regularization | Bishop 2006 §9.2.2 |
| 06 | 06-model-selection.md |
How many states: AIC/BIC/ICL, why they disagree, states-as-lack-of-fit | Pohle et al. 2017 |
Part II — Tooling & Evaluation
| Module | File | Focus | Anchor sources |
|---|---|---|---|
| 07 | 07-hmmlearn.md |
hmmlearn deep dive: API, reg_covar, monitoring, maintenance status |
hmmlearn docs/changelog |
| 08 | 08-pomegranate-dynamax.md |
pomegranate v1 (PyTorch/GPU) and dynamax (JAX); when to reach beyond hmmlearn | library docs |
| 09 | 09-statsmodels-markov-switching.md |
MarkovRegression / MarkovAutoregression; MS-AR vs plain HMM; Kim smoother | Hamilton 1989; statsmodels docs |
| 10 | 10-diagnostics-evaluation.md |
Viterbi vs posterior decoding; pseudo-residuals; HMM cross-validation | Zucchini et al. 2016 |
Part III — Modern Practice Across Domains
| Module | File | Focus | Verdict |
|---|---|---|---|
| 11 | 11-bioinformatics-profile-hmms.md |
Profile HMMs, HMMER, Pfam/InterPro | thriving |
| 12 | 12-speech-audio.md |
HMM-GMM to wav2vec2/CTC/RNN-T; forced-alignment survival (MFA, k2) | legacy-but-alive |
| 13 | 13-nlp-sequence-labeling.md |
HMM POS tagging as the teaching device vs BiLSTM-CRF/transformers | historical |
| 14 | 14-ecology-other-domains.md |
moveHMM telemetry; activity-recognition baselines; the unverified-domains checklist | thriving / mixed |
Part IV — Finance Regime Practice
| Module | File | Focus | Gate |
|---|---|---|---|
| 15 | 15-causal-regime-detection.md |
Filtered states only; refit discipline; no smoothed-state lookahead | project card |
| 16 | 16-routing-costs-turnover.md |
Routing/sizing overlays; turnover; transaction-cost accounting | net-of-cost framing |
| 17 | 17-honest-validation.md |
Purged OOS; jump-model and threshold baselines; why gross curves lie | acceptance gates |
| 18 | 18-capstone-project.md |
Full project card: HMM vs jump model vs threshold router | full gates |
References Standard
Every module ends in a References section listing sources by role:
- Mechanics — proves how something works (papers, official docs).
- Survey — domain-status evidence with retrieval dates.
- Edge evidence / adversarial — out-of-sample comparisons, honest backtests; labeled with what they do and do not show.
- Background — practitioner education, explicitly labeled as such.
Rejected sources are kept in a per-module exclusion line where the rejection reason teaches something (e.g., a trading-course source without out-of-sample or cost methodology).
Suggested Study Paths
- “I need to fit and trust an HMM on my own data” — 00 → 01 → 02 → 04 → 05 → 07 → 10.
- “I want to know if HMMs still matter before investing effort” — 00 → 11 → 12 → 13 → 14 → 17.
- “I want to use HMMs for market regimes” — 00 → 03 → 07 → 15 → 16 → 17 → 18 (all of Part IV is mandatory).
- “I teach or onboard others” — full canonical order; do not skip 05 and 06, the two most-skipped and most-costly modules.