Out-of-distribution (OOD) generalisation addresses the failure of the i.i.d. assumption underlying classical statistical learning. In deployment, test inputs are drawn from a distribution $P_\mathrm{test}$ that differs from the training distribution $P_\mathrm{train}$. Standard generalisation bounds, VC, Rademacher, PAC-Bayes, apply only when $P_\mathrm{test} = P_\mathrm{train}$ and provide no guarantees under shift.
Taxonomy of distribution shift. Decomposing $P(x, y) = P(x) P(y \mid x) = P(y) P(x \mid y)$ gives standard categories:
- Covariate shift. $P_\mathrm{train}(x) \neq P_\mathrm{test}(x)$ but $P(y \mid x)$ is unchanged. Example: a chest X-ray classifier trained on adults applied to paediatric patients, the conditional disease probability per image features is similar but image distributions differ.
- Label shift (prior shift). $P_\mathrm{train}(y) \neq P_\mathrm{test}(y)$ but $P(x \mid y)$ is unchanged. Example: disease prevalence differs between hospitals while symptom distributions per disease remain stable.
- Concept drift. $P(y \mid x)$ changes over time; $P(x)$ may also change. Example: spam classifier as spammers adapt; medical guidelines shifting which findings are considered abnormal.
- Domain shift. Both $P(x)$ and $P(y \mid x)$ may differ. Example: a model trained on simulator images deployed on real photographs.
Importance weighting. Under covariate shift with known density ratio $w(x) = P_\mathrm{test}(x) / P_\mathrm{train}(x)$, the test risk equals
$$R_\mathrm{test}(f) = \mathbb{E}_{P_\mathrm{train}}[w(x) \ell(f(x), y)]$$
so reweighted empirical risk minimisation is unbiased. In practice $w$ must be estimated, and high variance ratios cause instability.
Generalisation bounds under shift. Ben-David et al. (2010) gave the canonical bound for binary classification:
$$R_T(h) \leq R_S(h) + \tfrac{1}{2} d_{\mathcal{H} \Delta \mathcal{H}}(P_S, P_T) + \lambda^*$$
where $d_{\mathcal{H} \Delta \mathcal{H}}$ is the $\mathcal{H}$-divergence between source and target marginals (estimable from unlabelled samples) and $\lambda^*$ is the joint minimum risk on both domains. This motivates domain-invariant representations: train a feature map $\phi$ such that $P_S(\phi(x))$ and $P_T(\phi(x))$ are indistinguishable while preserving label information.
Methods.
- Domain-adversarial networks (Ganin et al., 2016). A discriminator tries to distinguish source from target features; the encoder adversarially fools it.
- Invariant risk minimisation (Arjovsky et al., 2019). Find a representation such that the optimal classifier is the same across all training environments. Formalised as a bilevel optimisation $\min_\phi \sum_e R_e(w \circ \phi)$ subject to $w \in \arg\min_{\tilde w} R_e(\tilde w \circ \phi)$ for every environment $e$.
- Group distributionally robust optimisation (Sagawa et al., 2020). Minimise worst-case risk over predefined groups: $\min_\theta \max_g R_g(\theta)$.
- Test-time adaptation. Update batch normalisation statistics or a small set of parameters using unlabelled test data.
- Causal approaches. If the causal mechanism $P(y \mid \mathrm{pa}(y))$ is invariant, models that condition only on causes generalise to interventions.
Why it matters in clinical AI. Hospitals, scanners, demographics, and disease prevalences vary across deployment sites. A radiology model with 95% AUC at the training hospital can drop below 70% at another. OOD generalisation is therefore a safety requirement, not just an academic concern.
Negative results. Gulrajani and Lopez-Paz (2021) showed that on standard benchmarks no domain generalisation method consistently beats empirical risk minimisation with careful hyperparameter tuning, suggesting current methods are far from solving OOD generalisation. Robustness to natural distribution shift remains one of the central open problems in deep learning.
Related terms: Manifold Hypothesis, Statistical Learning Theory, Regularisation, Implicit Regularisation
Discussed in:
- Chapter 6: ML Fundamentals, Robustness and Distribution Shift