Course contentsShow
← Machine Learning and Deep Learning
Lesson 2528 of 3,53854. Graph Neural NetworksFree lesson

Traffic and Spatial-Temporal Forecasting

Modeling road networks and sensor graphs to predict traffic flow, congestion, and spatial-temporal patterns.

Traffic and Spatial-Temporal Forecasting

What you'll learn: How to use Graph Neural Networks to predict traffic conditions by modeling road networks as graphs with time-evolving patterns.

The Core Idea

Imagine a city's road network: intersections are nodes, roads are edges, and traffic sensors measure flow at each location. Traffic isn't just about one spot—it's about how congestion spreads spatially (across connected roads) and temporally (over time). GNNs excel here because they capture both dimensions simultaneously.

Why Graphs for Traffic?

Traditional time series models treat each sensor independently, missing crucial spatial dependencies. A traffic jam on Main Street affects connected avenues. By representing the road network as a graph:

  • Nodes = traffic sensors or road segments
  • Edges = physical road connections
  • Node features = speed, volume, occupancy at each time step
  • Edge features = road capacity, distance, or number of lanes

Spatial-Temporal Modeling

The challenge is capturing spatial correlations (nearby sensors influence each other) and temporal dynamics (traffic patterns evolve over minutes/hours). Modern approaches combine:

  1. GNN layers for spatial aggregation—message passing captures how traffic propagates through the network
  2. Temporal modules (like recurrent layers or temporal convolutions) that track how patterns evolve at each node

You've seen temporal GNNs in lesson 2521—traffic forecasting is their killer application. The model learns that rush hour spreads predictably, accidents create cascading delays, and weekend patterns differ from weekdays.

Real-World Applications

Transit authorities use these models to predict congestion 15-60 minutes ahead, optimize signal timing, and recommend routes. The spatial-temporal structure is what makes GNNs uniquely suited compared to treating each sensor as an isolated time series.

Key Takeaway: Traffic forecasting leverages GNNs to model road networks as graphs, using message passing to capture spatial dependencies between connected roads while temporal components track how patterns evolve, enabling accurate prediction of congestion and flow across the entire network.