Counterfactual explanations for deep learning-based traffic forecasting

Rushan Wang, Yanan Xin, Yatao Zhang, Fernando Pérez‐Cruz, Martin Raubal

TL;DR

This paper introduces a framework for generating counterfactual explanations (CFEs) to demystify "black-box" deep learning models used in traffic forecasting. By identifying the minimal changes in input features (like the number of nearby businesses or lane counts) required to achieve a target traffic speed, the authors provide urban planners and engineers with actionable, scenario-driven insights into how complex spatiotemporal models actually make decisions.

What Problem Does This Paper Address?

Deep learning has revolutionized traffic forecasting, achieving high accuracy by capturing complex spatial and temporal patterns. However, these models are notoriously opaque. For a city planner, knowing that a model predicts a traffic jam is only half the battle; they need to understand why the model made that prediction and what "levers" (e.g., changing speed limits or infrastructure) might alter the outcome.

Traditional Explainable AI (XAI) methods often rely on simpler "surrogate" models that may not be entirely faithful to the original complex model. This paper tackles the challenge of providing high-fidelity explanations for spatiotemporal data—a difficult task due to the high dimensionality and interconnected nature of road networks.

Methods

The authors propose a two-part approach: a high-performance forecasting model and a multi-objective explanation framework.

  1. The Forecasting Model: They use a hybrid architecture combining Graph Convolutional Networks (GCN) to handle spatial dependencies (how one road affects another) and Gated Recurrent Units (GRU) to process temporal patterns (how traffic changes over time). The architecture of the deep learning model used in this study for traffic forecasting. The architecture of the Gated Recurrent Unit (GRU) model.
The architecture of the deep learning model used in this study for traffic forecasting.
The architecture of the Gated Recurrent Unit (GRU) model.
  1. The Explainer (MOC): To generate counterfactuals, they use Multi-Objective Counterfactuals (MOC) powered by a genetic algorithm (NSGA-II). This searches for "what-if" scenarios that satisfy four criteria:
  2. Validity: Does the change actually produce the target speed?
  3. Proximity: Is the change minimal compared to the original state?
  4. Sparsity: Are we changing as few features as possible?
  5. Plausibility: Does the resulting scenario look like real-world data?
  6. Scenario-Driven Constraints: A key novelty is the ability for users to add Directional Constraints (e.g., "only show me what happens if I increase the number of lanes") and Weighting Constraints (e.g., "don't suggest changes to the speed limit").

Datasets

The study utilizes traffic speed data provided by HERE Technologies for Thousand Oaks, California.

  • Road Network: 3,169 road segments.
  • Temporal Scope: Data collected at 5-minute intervals throughout January 2019.
  • Contextual Features: The model incorporates both static and dynamic data, as summarized in the table below: Summary of the contextual data in this study and their encoding method.
Summary of the contextual data in this study and their encoding method.

Key Insights and Ideas

  • Contextual Sensitivity: The model doesn't just look at past speeds; it learns how the environment impacts flow. For example, on suburban roads, the model associates a higher density of Points of Interest (POIs) with higher speeds, likely because it identifies these areas as quieter residential zones compared to busy commercial arterials.
  • Urban vs. Suburban Logic: On urban roads, the logic flips. To increase speed, the counterfactuals often suggest reducing the number of POIs, reflecting the reality that high-density attractions in city centers drive congestion.
  • Highway Invariance: Interestingly, the counterfactuals showed that static features like POIs have almost no impact on highway speed predictions. This makes sense: highways are "closed" systems where traffic is driven by inflow/outflow and historical trends rather than a nearby restaurant.
  • Actionable Planning: The framework can suggest non-obvious solutions. In one scenario, the model suggested reducing lane counts on upstream segments to "meter" traffic, leading to smoother flow and higher speeds on the target road segment.

Key Results

The forecasting model itself proved highly robust, achieving an accuracy of 91.24%. Traffic forecasting model performance.

Traffic forecasting model performance.

In the explanation phase, the framework successfully generated valid counterfactuals. For a suburban road where the original predicted speed was 30.10 km/h, the CFE identified a set of feature modifications (adjusting POIs and lanes) that moved the predicted speed to 54.65 km/h, nearly hitting the 56 km/h target.

Limitations and Future Work

The authors acknowledge several areas for growth:

  • Geographic Generalizability: The current model is trained on a specific region in California. Its learned correlations might not hold true in cities with vastly different layouts (e.g., European medieval centers).
  • Feature Granularity: "POIs" are currently treated as a single number. Future work should distinguish between types of POIs (e.g., a school vs. a gas station), as they have very different impacts on traffic.
  • Dynamic Counterfactuals: The study primarily modified static features. The authors suggest expanding this to "time-series counterfactuals," exploring how changing dynamic factors like weather or previous-hour speeds would alter the forecast.
  • Human-in-the-loop: Future research should involve direct collaboration with urban planners to ensure the generated explanations are practically useful for policy-making.

Summary updated

BibTeX
@inproceedings{wang2025counterfactual,
  author = {Rushan Wang and Yanan Xin and Yatao Zhang and Fernando Pérez‐Cruz and Martin Raubal},
  title = {{Counterfactual explanations for deep learning-based traffic forecasting}},
  booktitle = {Communications},
  year = {2025},
  doi = {10.1016/j.commtr.2025.100176},
}
Figure