Skip to main content
QUICK REVIEW

[Paper Review] Counterfactual Invariance to Spurious Correlations: Why and How to Pass Stress Tests

Victor Veitch, Alexander D’Amour|arXiv (Cornell University)|May 31, 2021
Topic ModelingComputer Science17 citations
TL;DR

This paper formalizes stress testing in machine learning through counterfactual invariance, showing that predictors should remain unchanged when irrelevant input features (e.g., gender or sentiment in text) are perturbed. It derives observable, testable conditions based on causal structure—distinguishing between causal and anti-causal data models—and provides regularization schemes to learn predictors robust to domain shifts, with empirical validation in text classification.

ABSTRACT

Informally, a 'spurious correlation' is the dependence of a model on some aspect of the input data that an analyst thinks shouldn't matter. In machine learning, these have a know-it-when-you-see-it character; e.g., changing the gender of a sentence's subject changes a sentiment predictor's output. To check for spurious correlations, we can 'stress test' models by perturbing irrelevant parts of input data and seeing if model predictions change. In this paper, we study stress testing using the tools of causal inference. We introduce counterfactual invariance as a formalization of the requirement that changing irrelevant parts of the input shouldn't change model predictions. We connect counterfactual invariance to out-of-domain model performance, and provide practical schemes for learning (approximately) counterfactual invariant predictors (without access to counterfactual examples). It turns out that both the means and implications of counterfactual invariance depend fundamentally on the true underlying causal structure of the data -- in particular, whether the label causes the features or the features cause the label. Distinct causal structures require distinct regularization schemes to induce counterfactual invariance. Similarly, counterfactual invariance implies different domain shift guarantees depending on the underlying causal structure. This theory is supported by empirical results on text classification.

Motivation & Objective

  • To formalize stress testing as counterfactual invariance, ensuring model predictions are stable under interventions on irrelevant input features.
  • To clarify the connection between counterfactual invariance and out-of-domain generalization by analyzing underlying causal structures.
  • To develop practical, data-driven regularization methods that enforce counterfactual invariance without requiring access to counterfactual examples.
  • To demonstrate that different causal structures (causal vs. anti-causal) necessitate distinct training strategies for achieving invariance and robustness.

Proposed method

  • Introduces counterfactual invariance as a formal condition: a predictor must produce identical outputs under interventions on spurious features Z, i.e., f(X(z)) = f(X(z')) almost everywhere.
  • Derives observable implications of counterfactual invariance using conditional and marginal independence criteria (e.g., f(X) ⊥ Z | Y), which can be tested on observed data.
  • Proposes regularization schemes that enforce these independence conditions during training, enabling approximate counterfactual invariance without generating counterfactual examples.
  • Distinguishes between two key causal structures: (1) Y causes X, with Z influencing X (causal direction), and (2) Z and Y share a common cause, with X being a function of both (anti-causal direction), each requiring different regularization strategies.
  • Applies the framework to text classification, using real-world datasets to validate that models trained under these criteria pass stress tests and generalize better under domain shifts.
  • Connects counterfactual invariance to fairness and domain adaptation by showing equivalence to concepts like demographic parity and equalized odds under specific interpretations.

Experimental results

Research questions

  • RQ1How can stress testing be formalized using causal inference to ensure model robustness to spurious correlations?
  • RQ2What are the observable, testable conditions that imply counterfactual invariance in real-world data?
  • RQ3How does the underlying causal structure (causal vs. anti-causal) affect the design of regularization methods for achieving counterfactual invariance?
  • RQ4What guarantees does counterfactual invariance provide for out-of-domain generalization, and how do they vary with causal structure?
  • RQ5Can counterfactual invariance be enforced without access to counterfactual examples, and if so, how?

Key findings

  • Counterfactual invariance is formalized as a condition requiring f(X(z)) = f(X(z')) for all z, z' in the support of Z, ensuring predictions are invariant to irrelevant perturbations.
  • The paper identifies two distinct causal structures—causal (Y → X, Z → X) and anti-causal (Z and Y share a common cause)—that require fundamentally different regularization strategies to achieve invariance.
  • Observable independence criteria (e.g., f(X) ⊥ Z | Y) are derived as sufficient conditions for counterfactual invariance, enabling training without counterfactual data.
  • The method improves out-of-domain generalization, as models trained under these criteria show better robustness to distributional shifts, particularly when the causal structure is correctly identified.
  • Empirical results on text classification confirm that models trained with the proposed regularization schemes pass stress tests and generalize better under domain shifts.
  • The framework reveals that naive application of fairness-inspired regularization (e.g., from counterfactual fairness) may fail in anti-causal settings, highlighting the need for structure-aware design.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.