Distributionally Robust Learning in Heterogeneous Contexts

Muhammad Osama, Dave Zachariah, Petre StoicaarXiv 2021

Abstract

We consider the problem of learning from training data obtained in different contexts, where the underlying context distribution is unknown and is estimated empirically. We develop a robust method that takes into account the uncertainty of the context distribution. Unlike the conventional and overly conservative minimax approach, we focus on excess risks and construct distribution sets with statistical coverage to achieve an appropriate trade-off between performance and robustness. The proposed method is computationally scalable and shown to interpolate between empirical risk minimization and minimax regret objectives. Using both real and synthetic data, we demonstrate its ability to provide robustness in worst-case scenarios without harming performance in the nominal scenario.

Introduction

Machine learning models are frequently trained on data pooled from various sources, environments, or demographics—referred to as "contexts." For example, medical data might be collected from several different hospitals, or autonomous driving data from different weather conditions. The challenge arises because the true real-world distribution of these contexts is usually unknown.

Standard Empirical Risk Minimization (ERM) minimizes the average error across training data, which can severely underrepresent rare contexts. Conversely, the classic "minimax" approach optimizes for the absolute worst-case context, which is often overly conservative and can force the model to focus on inherently noisy or impossible-to-predict scenarios. This paper proposes a "Goldilocks" solution that optimizes for worst-case excess risk within a statistically defined confidence set.

Methodology

The proposed method combines two key concepts from decision theory to balance performance and robustness:

  1. Excess Risk (Regret): Instead of looking at absolute risk, the method evaluates excess risk—how much worse the model performs compared to the theoretical best possible model for that specific context. This prevents the model from obsessing over contexts that are simply noisy and unlearnable.
  2. Confidence-Based Distribution Sets: Instead of preparing for any worst-case distribution, the method constructs a plausible "confidence set" of distributions using Kullback-Leibler (KL) divergence. The size of this boundary is controlled by a user-specified confidence level $\beta$ and the amount of training data $n$.

The resulting objective minimizes the worst-case excess risk only over the distributions within this confidence set. The authors provide a computationally efficient gradient descent algorithm that uses Danskin's theorem to differentiate through the inner maximization step.

Datasets and Experimental Setup

The authors evaluate their method on a mix of synthetic and real-world datasets:

  • Synthetic Stock Control: A 10-context dataset simulating demand and cost, where one context is highly prevalent and others are scarce.
  • Synthetic Binary Classification: A 3-context dataset with 2D covariates to visualize decision boundaries.
  • Colored MNIST: A modified benchmark where digits are grouped into binary classes and synthetically colored. The correlation between color and label varies across 5 contexts, acting as a spurious feature.
Contextual heterogeneity in the synthetic stock control dataset showing demand vs. cost across two contexts.

Key Insights: Risk vs. Excess Risk

A core insight of the paper is that minimizing excess risk is superior to absolute risk for robustness. By focusing on regret, the model naturally ignores contexts with high but irreducible error rates, focusing its capacity where parameter choices actually make a difference.

Comparison of absolute risk (a) and excess risk/regret (b) across different contexts.

As shown in Figure 6, the excess risk formulation (b) allows for a clearer identification of the optimal parameters $\theta$ that minimize regret across heterogeneous contexts. Furthermore, the KL-divergence confidence set acts as a smart regularizer: with little data, the model acts cautiously (closer to minimax); as data $n$ increases, it naturally shifts toward standard ERM.

Results

  • Stock Control Task: The robust method reduced worst-case excess risk to ~60, compared to ~105 for ERM and ~80 for the standard minimax approach. This gain in worst-case robustness came at a very minor cost to nominal performance (excess risk of 28 vs. 23 for ERM).
  • Classification Task: The method learned decision boundaries that successfully accounted for less frequent contexts, significantly reducing worst-case excess error rates.
  • Colored MNIST: The proposed method successfully ignored spurious color correlations in worst-case contexts, significantly reducing worst-case excess error compared to ERM, while standard minimax solvers failed to converge to a reasonable solution.

Conclusion

By optimizing for worst-case excess risk within statistically grounded confidence sets, this method provides a principled way to handle heterogeneous data. It achieves strong worst-case robustness without sacrificing nominal performance. Future work may extend this to continuous context variables and explore applications in algorithmic fairness and medical diagnostics.

Summary updated

BibTeX
@misc{osama2021distributionally,
  author = {Muhammad Osama and Dave Zachariah and Petre Stoica},
  title = {{Distributionally Robust Learning in Heterogeneous Contexts}},
  year = {2021},
  eprint = {2105.08532},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.08532},
}
Figure