A Unified Causal View of Domain Invariant Representation Learning

Zihao Wang, Victor Veitch

TL;DR

Why do domain generalization methods like Invariant Risk Minimization (IRM), adversarial feature alignment, and data augmentation succeed in some benchmarks but catastrophically fail in others? This paper introduces Causally Invariant with Spurious Associations (CISA), a unifying causal framework revealing that no single invariance method works universally—the right approach depends strictly on the underlying causal direction between inputs, labels, and confounders.

What Problem Does This Paper Address?

Machine learning models frequently fail when deployed in new environments because they latch onto spurious correlations present in their training data (e.g., associating cows with green pastures and camels with sand). To combat this, researchers aim to learn domain-invariant representations that discard spurious variations while retaining stable predictive signals.

However, existing empirical benchmarks reveal an unsettling pattern: no single domain generalization method consistently outperforms standard Empirical Risk Minimization (ERM). Techniques based on data augmentation, distributional matching, or invariant risk minimization often contradict one another. The fundamental challenge has been the lack of a formal, shared definition of what constitutes an "invariant representation" across domains.

Methods

The authors formalize domain shift using Causally Invariant with Spurious Associations (CISA). Under CISA:

  1. The structural causal relationships generating the covariates $X$ from latent factors remain fixed across domains.
  2. Spurious factors $Z$ influence a component of the covariates ($X_z$) and correlate with the label $Y$ due to an unobserved confounder $U$.
  3. The environment $E$ acts solely by changing the distribution of $U$.

Within this framework, the gold standard is Counterfactual Invariance (CF-invariance): a representation $\phi(X)$ should remain invariant under counterfactual interventions on the spurious factors $Z$ (i.e., $\phi(X)$ measures only $X_z^\perp$, the part unaffected by $Z$).

The authors classify CISA domains into three distinct causal DAG families and map existing representation learning methods as relaxations of CF-invariance:

  • Anti-Causal ($Y \to X_z^\perp$): Common in image classification. Implies conditional distributional invariance: $\phi(X) \perp\!\!\perp E \mid Y$.
  • Confounded-Outcome ($X_z^\perp \to Y$, $U \to Y$): Common in sentiment/helpfulness scoring. Implies marginal distributional invariance: $\phi(X) \perp\!\!\perp E$.
  • Confounded-Descendant ($X_z^\perp \to Y$, $U \to X_z^\perp$): Common in macroeconomic forecasting. Implies sufficiency: $Y \perp\!\!\perp E \mid \phi(X)$.
  • Generalized IRM (g-IRM): Standard IRM assumes $Y \perp\!\!\perp E \mid \phi(X)$ and fails in anti-causal settings under prior shift ($P_e(Y)$ varies). The authors propose g-IRM, which incorporates label importance weighting $P_0(Y) / P_e(Y)$ to relax conditional invariance.
       Ideal Goal: Counterfactual Invariance (CF-invariance)
                             │
       ┌─────────────────────┴─────────────────────┐
       ▼                                           ▼
Data Augmentation                      Distributional Invariance
(Exact if label-preserving &           (Relaxation; depends on causal graph)
 enumerates all outcomes of Z)                     │
                               ┌───────────────────┼───────────────────┐
                               ▼                   ▼                   ▼
                          Anti-Causal      Confounded-Outcome  Confounded-Descendant
                          ϕ(X) ⊥ E | Y         ϕ(X) ⊥ E            Y ⊥ E | ϕ(X)
                               │                                       │
                               ▼                                       ▼
                             g-IRM                                Vanilla IRM

Datasets

The authors demonstrate their theoretical findings using controlled synthetic benchmarks adapted from the Two-Bit-Environments setup:

  • Anti-Causal Two-Bit-Envs: Mimics ColoredMNIST with label-shift. $Y \in \{-1, 1\}$, invariant core feature $X_1 = Y \cdot \text{Rad}(\alpha)$ ($\alpha = 0.25$), and spurious feature $X_2 = Y \cdot \text{Rad}(\beta_e)$. Four training domains feature prior shift ($\gamma_e \in \{0.9, 0.1, 0.7, 0.3\}$) and strong spurious correlations ($\beta_e \in [0.05, 0.2]$). In the test domain, $\gamma = 0.5$ and the correlation flips ($\beta = 0.9$).
  • Confounded-Descendant Two-Bit-Envs: The causal direction is inverted ($X_1 \to Y \to X_2$). Imbalance is generated via covariate shift in $X_1$ rather than prior shift in $Y$.
  • Prior Empirical Benchmarks: The paper contextualizes empirical findings from established benchmarks, including WILDS and domain generalization suites from Gulrajani & Lopez-Paz (2020) and Wiles et al. (2021).

Key Insights and Ideas

  • No universal invariance criterion exists: Enforcing the wrong distributional invariance directly contradicts counterfactual invariance and increases dependence on spurious features.
  • Ideal data augmentation is structure-agnostic: If a set of transformations is truly label-preserving and spans all variations of $Z$, it provably recovers the optimal CF-invariant predictor regardless of whether the causal graph is anti-causal or causal.
  • Standard IRM fundamentally fails under anti-causal prior shift: When $Y$ causes $X$ and domain shift includes label proportion shifts ($P_e(Y)$), the Bayes-optimal classifier shifts across domains, causing the set of invariant risk minimizers to be empty ($\Phi_{\text{IRM}} = \emptyset$).
  • Techniques like importance sampling have causal consequences: Re-weighting by $P(Y)$ fixes IRM in anti-causal settings, but applying it to confounded-descendant graphs actually destroys the stable causal relationship between $X_1$ and $Y$.

Key Results

In the Two-Bit synthetic experiments:

  • Anti-Causal Setting (Table 1):
  • Vanilla IRMv1 failed to discard spurious feature $X_2$, yielding asymmetric predictor weights ($f(1, 1) = 2.53$ vs. $f(1, -1) = -0.93$).
  • g-IRMv1 successfully ignored $X_2$ ($f(1, 1) = 1.16$, $f(1, -1) = 1.08$), achieving the theoretical optimal test accuracy of 75%.
  • Confounded-Descendant Setting (Table 2):
  • Vanilla IRMv1 cleanly eliminated $X_2$ ($f(1, 1) = 1.1$, $f(1, -1) = 1.1$).
  • g-IRMv1 destroyed the invariant link; its weights collapsed to 0 everywhere, predicting the trivial majority class.

Limitations and Future Work

  • Unobtainable transformations in practice: While ideal data augmentation is the gold-standard theoretical solution, real-world spurious factors $Z$ are unobserved, making it difficult to guarantee that augmentations are strictly label-preserving without causing manifold intrusion.
  • The Confounded-Outcome roadblock: When confounding directly influences the outcome ($U \to Y$), neither IRM nor g-IRM guarantees invariant risk without strong parametric assumptions (e.g., additive noise models).
  • Scope of domain shifts: CISA assumes fixed structural relationships and shifting confounder distributions. It does not cover settings where testing domains are adversarial or fundamentally out of support.

Summary updated

BibTeX
@inproceedings{wang2023unified,
  author = {Zihao Wang and Victor Veitch},
  title = {{A Unified Causal View of Domain Invariant Representation Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=dr56zCCLtqY},
}
Figure