diffIRM: A Diffusion-Augmented Invariant Risk Minimization Framework for Spatiotemporal Prediction over Graphs

Zhaobin Mo, Haotian Xiang, Xuan Di

TL;DR

diffIRM is a novel framework that tackles the "out-of-distribution" (OOD) problem in spatiotemporal graph prediction by combining diffusion-based data augmentation with Invariant Risk Minimization (IRM). By using a graph-based diffusion model to generate diverse synthetic environments while shielding "causal" features, it trains models that remain robust even when real-world data patterns shift unexpectedly.

What Problem Does This Paper Address?

Spatiotemporal prediction over graphs (STPG)—like forecasting traffic flow or human mobility—usually assumes that the future will look like the past. However, real-world data is often "non-stationary." A model trained on traffic data from 2019 might fail miserably in 2020 because the COVID-19 pandemic fundamentally shifted human behavior. This is known as the Out-of-Distribution (OOD) generalization problem.

An illustrative example of the distribution shift for ST graph data due to the Omicron variant.

While Invariant Risk Minimization (IRM) has been successful in image processing for finding "invariant" features (like the shape of a camel vs. its background), it struggles with graphs. In graph data, the "environment" (e.g., weather, holidays, or a pandemic) is deeply entangled with the spatial correlations of the nodes. Existing methods usually focus on either finding invariant features or diversifying training data, but rarely both.

Methods

The authors propose diffIRM, which integrates three major OOD strategies: causality-based identification, invariant learning, and data augmentation.

  1. Environment Augmentation via Diffusion: The framework uses a graph-based denoising diffusion probabilistic model (DDPM). Unlike standard diffusion used for images, this one uses Graph Convolutional Networks (GCNs) to respect the spatial structure of the data. It generates multiple synthetic "environments" by adding controlled noise to the data.
  2. Causal Mask Generator: To ensure the diffusion process doesn't destroy the very features needed for prediction, an MLP-based "causal mask generator" identifies which features are causal (invariant) and which are environmental (spurious). Causal features are kept stable, while environmental features are diversified by the diffusion model.
  3. The Min-Max Game: The training is formulated as a game where the environment augmentor tries to maximize prediction error (creating "hard" environments), while the mask generator and the prediction model work together to minimize it.
  4. Invariance Penalty: Following the principles of IRM, a penalty term is added to the loss function. This forces the prediction model to find a solution that is simultaneously optimal across all the diverse, augmented environments.
Overview of the proposed diffIRM framework showing the data augmentation and invariant learning processes.

Datasets

The model was evaluated on both synthetic and real-world data:

  • Numerical SCM: A toy dataset generated from a known Structural Causal Model to verify if the model can truly identify ground-truth causal features.
  • SafeGraph: Weekly human mobility (visit counts) across 172 zip codes in New York City, spanning the pre- and post-outbreak periods of the Omicron variant.
  • PeMS04 & PeMS08: Standard traffic datasets from California (Bay Area and San Bernardino) including flow, occupancy, and aggregated contextual features like road incidents and lane closures.

Key Insights and Ideas

  • Bridging the Gap: As shown in the table below, diffIRM is the first to combine causality-based methods, invariant learning, and data augmentation for spatiotemporal prediction.
Comparison of diffIRM with other graph OOD methods across categories and principles.
  • Diffusion as an "Environment Factory": Instead of needing to know exactly what the different environments are (e.g., "this is rainy day data," "this is holiday data"), diffIRM uses diffusion to generate a spectrum of possible environments, making it much more flexible for real-world applications where latent factors are unknown.
  • Model Agnostic: The framework acts as a "wrapper" or regularizer. The authors showed it works effectively whether the underlying prediction model is an LSTM, a Spatiotemporal Convolutional Graph Network (STCGN), or an Attention-based GCN (ASTGCN).

Key Results

  • Superior Accuracy: On the SafeGraph dataset, where the OOD shift was most severe, diffIRM reduced the Mean Absolute Error (MAE) by over 75% compared to standard Empirical Risk Minimization (ERM).
  • Robustness to Shift: While baselines like IRM and REx showed some improvement over standard training, diffIRM consistently outperformed them across all three real-world datasets.
  • Interpretability: The causal masks generated by the model were found to be intuitive. For example, in the SafeGraph data, the model correctly identified that "confirmed COVID cases" became a much more critical causal feature for predicting mobility after the pandemic started compared to before.

Limitations and Future Work

  • Optimization Complexity: The min-max optimization required for training is computationally intensive and can be difficult to converge compared to standard supervised learning.
  • Intra-test OOD: The current version assumes the test data comes from a different but fixed distribution. It does not yet account for "highly temporally non-stationary" scenarios where the distribution might continue to shift during the testing phase.
  • Future Directions: The authors suggest exploring frameworks that achieve similar robustness without the heavy computational lift of data augmentation.

Summary updated

BibTeX
@inproceedings{mo2025diffirm,
  author = {Zhaobin Mo and Haotian Xiang and Xuan Di},
  title = {{diffIRM: A Diffusion-Augmented Invariant Risk Minimization Framework for Spatiotemporal Prediction over Graphs}},
  booktitle = {Transportation Science},
  year = {2025},
  url = {https://openreview.net/forum?id=3AcYbYQkVB},
}
Figure