Provable Domain Generalization via Invariant-Feature Subspace Recovery

Haoxiang Wang, Haozhe Si, Bo Li, Han Zhao

The Challenge of Spurious Correlations

Machine learning models often fail when deployed in real-world settings because they rely on spurious correlations—patterns that exist in training data but do not hold generally. A classic example is a model that learns to identify "cows" by looking for "green grass." If the test set contains a cow on a beach, the model fails.

Domain Generalization (DG) aims to solve this by training on multiple "environments" (e.g., photos of cows in fields, forests, and mountains) to find features that are invariant across all of them. The current standard, Invariant Risk Minimization (IRM), attempts to find a representation where the optimal classifier is consistent across environments. However, IRM requires a large number of training environments and suffers from highly non-convex optimization, often leading to local minima.

Invariant-Feature Subspace Recovery (ISR)

This paper introduces Invariant-Feature Subspace Recovery (ISR), a provably optimal approach to DG that identifies invariant features using linear algebra. The authors treat domain generalization as a subspace recovery problem, assuming a linear Gaussian data model where observed features $x$ are a mixture of invariant components ($z_c$) and spurious components ($z_e$).

Causal graph of the data generating process, where $y$ is the label, $e$ is the environment, $z_c$ are invariant features, and $z_e$ are spurious features.

The authors propose two primary algorithms:

  1. ISR-Mean: This algorithm analyzes the first-order moments (means) of class-conditional distributions across environments. By performing Principal Component Analysis (PCA) on these means, the algorithm identifies the subspace where spurious features reside, leaving the invariant subspace as the remainder.
  2. ISR-Cov: A more powerful variant that utilizes second-order moments (covariances). If the variance of invariant features is constant while the variance of spurious features changes between environments, the difference between covariance matrices reveals the spurious subspace.

Unlike IRM's complex bi-level optimization, ISR uses standard eigen-decomposition and Empirical Risk Minimization (ERM). This ensures computational efficiency and guarantees global convergence to the optimal solution.

Key Insights and Theoretical Breakthroughs

  • The $O(1)$ Environment Requirement: A striking finding is that ISR-Cov only needs $E \ge 2$ environments to recover the invariant subspace. This is the theoretical minimum required to distinguish invariant from spurious features.
  • Phase Transition in Eigenvalues: In ideal settings, the eigenvalues of the mean or covariance difference matrices show a clear split: the first $d_c$ (dimension of invariant features) eigenvalues are zero, while the rest are positive. This provides a clear mathematical signal for isolating the invariant subspace.
  • Post-Processing Power: ISR can be used as a "plug-and-play" post-processing step for pre-trained models (like ResNet or CLIP). By extracting features and applying ISR, one can "clean" the final linear layer of spurious dependencies.

Empirical Results

The paper evaluates ISR on synthetic benchmarks and real-world datasets like Waterbirds, CelebA, and MultiNLI.

Mean error across various synthetic benchmarks as a function of the number of training environments $E$. ISR-Cov (orange) achieves near-oracle performance with as few as two environments.

On synthetic "Linear Unit-Tests," ISR-Cov reached oracle performance with just 2 environments, whereas IRM and other variants required significantly more data or failed to reach the oracle entirely. In real-world applications, applying ISR-Mean as a post-processor to a standard ERM model on the Waterbirds dataset boosted Worst-Group Accuracy from 62.9% to 76.1%, with ISR-Cov reaching 82.5%.

Limitations and Future Work

While ISR provides strong theoretical guarantees, it currently relies on a linear data model. Empirical results show it works well as a post-processor for non-linear neural networks, but theoretical guarantees for deep feature extractors remain an open question. Additionally, ISR assumes that invariant features are already present in the representation; it cannot recover features that a pre-trained backbone has completely discarded.

Summary updated

BibTeX
@inproceedings{wang2022provable,
  author = {Haoxiang Wang and Haozhe Si and Bo Li and Han Zhao},
  title = {{Provable Domain Generalization via Invariant-Feature Subspace Recovery}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=sfsNmjMVb0},
}
Figure