Basic Prerequisites: 02 · GMM, 04 · HMM, and 05 · Failure Modes.


1. Intuition & Practical Objective

Regimes are rarely the end goal - they are the condition under which a trading model should behave differently. This page is the launchpad for using regimes in ML pipelines, in three escalating moves:

  1. Supervised regime labeling. If you have a regime proxy (a VIX threshold, an NBER flag, a drawdown rule), you don’t need clustering - train a classifier (logistic, tree) to predict the regime from features, and the regime becomes a target column in a standard supervised pipeline (ties to Tree & Boosting Methods).
  2. Regime-conditional models. Fit a separate prediction model per regime () instead of one global model. When the regime’s relationship to the features truly differs, the conditional model dominates.
  3. Soft regime weighting (mixture-of-experts). Because the regime call is uncertain (and label error is the killer from 05), the robust move is to blend the per-regime predictions by the regime posterior probability: . This is exactly how an HMM’s filtered probability is used downstream, and it inherits all the machinery of EM.

The one-sentence essence. “A regime is the context of a prediction; regime-conditional ML fits one model per regime and blends them by the regime probability - and the blending must be soft, because hard regime switches are where label error bites.”


2. Mathematical Ground Truth & Derivations

Supervised labeling. With a proxy label and features , logistic regression models

fit by maximum likelihood (gradient ascent on the cross-entropy). The fitted probabilities are the regime membership used downstream. (This is the ESL Ch 4 linear-classifier view; the tree/boosted version is Tree & Boosting.)

Regime-conditional forecast. Split the training data by regime, fit on and on , then predict

If the two regimes have opposite relationships (momentum in calm, mean-reversion in stress), a single pooled averages them toward zero - a biased predictor in both regimes - while the conditional model nails each.

Soft mixture (regime-weighted). Replace the hard indicator with the regime posterior:

This is the finite-mixture / mixture-of-experts predictor (ESL Ch 14; Jacobs et al. 1991), and it is robust to label error: a mislabeled hard switch applies the wrong sign model, whereas the soft weight merely down-weights the less-certain expert. This is the same logic that makes the HMM’s filtered probability (04) the correct object to feed a live strategy rather than a hard decoded state.


3. Computational Implementation - label, then condition, then blend

Two regimes with genuinely opposite dynamics (calm: positive drift + momentum; stress: negative drift + mean-reversion). Pipeline: (1) train a logistic labeler on features → OOS regime calls; (2) fit global, per-regime (hard), and soft-mixture forecasters; (3) compare OOS MSE. Stdlib only.

The table is the whole lesson of the folder, in four rows. Global is the naive single-model baseline. Oracle (true regime, an upper bound) improves - there is a huge regime-conditional edge to capture. But a hard switch on the predicted regime loses (): with opposite-sign regime models, the ~15% of mislabeled days apply the wrong sign and destroy the gain. The soft mixture - weighting the two per-regime models by the classifier’s posterior - captures a positive improvement robustly, because it never commits to a wrong hard label. That is why real regime-conditional ML blends softly (mixture-of-experts / filtered probability) instead of switching hard.


4. Failure Modes & First-Principles Breakdowns

  1. Hard regime-switching loses to label error (measured above: vs soft ). The regime call is uncertain; hard switches apply the wrong sign on mislabeled days. Fix: soft posterior weighting.
  2. The supervised label is only as good as its proxy. If your “regime” label (VIX threshold, drawdown rule) does not align with the model-relevant regime, you are conditioning on noise. Validate that the label separates the outcome, not just that it classifies.
  3. Look-ahead again. If the regime label or the labeler’s features use future data (e.g. a label built from a full-sample drawdown), the conditional edge is phantom (05). Train the labeler on PIT features and evaluate OOS.
  4. Per-regime overfitting. Splitting the data by regime shrinks each training set; with few stress days, overfits. Fix: shrinkage/regularization per regime (ESL Ch 18) or a shared feature backbone.

5. References

  • Jacobs, Jordan, Nowlan & Hinton, “Adaptive Mixtures of Local Experts,” Neural Computation 3(1):79–87, 1991
  • Hastie, Tibshirani & Friedman, The Elements of Statistical Learning
  • Ang & Timmermann, “Regime Changes and Financial Markets,” ARFE 4, 2012
  • López de Prado, Advances in Financial Machine Learning

6. Connected Graph Bridges