NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Learning Causal Models Online

Khurram Javed, Martha White, Yoshua BengioarXiv 2020

Abstract

Standard machine learning models often rely on spurious correlations, leading to failures in generalization when data distributions shift. This paper proposes a novel framework for discovering causal structures in an online setting by identifying and filtering spurious features—those whose correlation with a target variable fluctuates over time. By tracking the variance of feature weights using a modified Welford’s algorithm, the proposed method achieves systematic zero-shot generalization on shifting distributions. Crucially, this approach eliminates the need for explicit "environment labels" required by previous state-of-the-art methods like Invariant Risk Minimization (IRM). We demonstrate the effectiveness of this method on a modified Colored MNIST benchmark, where it matches the performance of an oracle-informed IRM baseline.

Introduction

Standard machine learning models are notorious for taking shortcuts. If a model learns to identify a "cow" based on the presence of green grass (a spurious correlation), it will fail when it encounters a cow on a beach. This is a fundamental failure of systematic generalization. To overcome this, models must understand causal structures rather than just statistical coincidences.

Traditionally, learning these structures is an offline, data-heavy process. Existing techniques like Invariant Risk Minimization (IRM) require data to be partitioned into distinct "environments" (e.g., "cows in fields" vs. "cows on beaches") to identify stable features. However, in real-world online learning, an agent does not receive these neat labels; it experiences a continuous, shifting stream of data. This paper argues that the temporal structure of online learning is a "feature, not a bug," providing the necessary signal to distinguish causal from spurious relationships.

Overview of the causal learning process across different tasks, from representation learning to causal explanation.

Methodology

Online Variance Tracking

The core insight is that if a feature is causally related to a target, its optimal weight should remain stable over time. Conversely, the correlation of a spurious feature will likely fluctuate as the environment changes. The algorithm tracks the running mean ($u_i$) and variance ($v_i$) of each feature's weight using a modified version of Welford’s algorithm. High variance in a weight serves as a "red flag" indicating that the feature is spurious and should be discounted.

Perturbations with Backtracking (PwB)

To learn features directly from raw sensory data (like pixels), the authors introduce Perturbations with Backtracking (PwB). This mechanism uses a weakly directed random search to update the weights of a representation-learning network.

The Perturbations with Backtracking (PwB) architecture for learning representations and reducing spurious features.

The model perturbs weights and observes the effect on two metrics: the running loss and the sum of weight variances ($v$). If a perturbation reduces either metric, it is retained; otherwise, the model "backtracks" to its previous state. This allows the model to discover stable, causal features without explicit supervision on environment shifts.

Experimental Evaluation

The approach was evaluated using a newly designed Online Colored MNIST benchmark. In this task, digits are colored red or green. In the training phase ("Seen MDP"), color is highly correlated with the digit label (e.g., 90% of 1s are green), but this correlation shifts slightly over time. In the test phase ("Unseen MDP"), the spurious color correlation is reversed or removed. Success requires the model to ignore color and focus entirely on the shape of the digit.

Key Results

  • Matching the Oracle: On the binary feature task, the proposed method achieved ~75% accuracy on the Unseen MDP, matching "Oracle IRM"—a baseline given the unfair advantage of knowing exactly when environment shifts occurred.
  • Failure of Standard Learning: A standard online learner (minimizing empirical risk) achieved only ~10% accuracy on the Unseen MDP, confirming its over-reliance on spurious color features.
  • Generalization from Pixels: Using the PwB algorithm, the model successfully learned to ignore colors and focus on shapes directly from raw images, achieving ~68.7% accuracy on unseen data, significantly outperforming standard gradient-based approaches.

Discussion and Future Work

A key takeaway is that shuffling data to make it Independent and Identically Distributed (IID) is counter-productive for causal discovery. Shuffling destroys the temporal signal needed to identify which correlations are shifting and which are stable.

The primary limitation of the current work is the reliance on random search for the PwB algorithm, which can be sample-inefficient in high-dimensional spaces. Future research will explore using sparsely connected networks to reduce the search space and developing more sophisticated heuristics to bias the search for stable perturbations.

Summary updated

BibTeX
@misc{javed2020learning,
  author = {Khurram Javed and Martha White and Yoshua Bengio},
  title = {{Learning Causal Models Online}},
  year = {2020},
  eprint = {2006.07461},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.07461},
}
Figure