Spatio-Temporal Self-Supervised Learning for Traffic Flow Prediction

Jiahao Ji, Jingyuan Wang, Chao Huang, Junjie Wu, Boren Xu, Zhenhe Wu, Junbo Zhang, Yu Zheng

TL;DR

ST-SSL is a novel traffic flow prediction framework that leverages self-supervised learning (SSL) to account for the inherent spatial and temporal heterogeneity of urban environments. By using adaptive graph augmentation and dual auxiliary tasks—soft clustering for spatial patterns and contrastive learning for temporal dynamics—it significantly outperforms state-of-the-art models, particularly in suburban areas and during off-peak hours.

What Problem Does This Paper Address?

Predicting citywide traffic flow is a cornerstone of intelligent transportation systems, yet it remains challenging due to two main types of heterogeneity:

  1. Spatial Heterogeneity: Different urban regions have vastly different functions. A residential area will have a completely different traffic "signature" than a major transportation hub or a shopping mall. Most existing models treat all regions uniformly, which biases them toward high-volume areas and leads to poor performance in quieter suburbs.
  2. Temporal Heterogeneity: Traffic patterns are not static; they shift dramatically between morning rushes, quiet nights, workdays, and holidays. Standard models often use a shared parameter space for all time periods, failing to capture these distinct temporal modes.
Figure 1: Illustration of our motivation, i.e., the spatial and temporal heterogeneity of traffic flow data.

The authors argue that current deep learning approaches either ignore these differences or use overly complex, multi-parameter strategies that are prone to overfitting and computationally expensive.

Methods

The ST-SSL (Spatio-Temporal Self-Supervised Learning) framework introduces a multi-stage approach to inject heterogeneity awareness into the learning process:

1. The Spatio-Temporal Encoder

The backbone is a "sandwich" block structure consisting of Temporal Convolutions (TC) and Spatial Convolutions (SC). This standard setup captures basic sequential patterns and local geographical correlations.

2. Adaptive Graph Augmentation

Unlike standard SSL which might use random masking, ST-SSL uses a heterogeneity-aware augmentation strategy. It calculates a "heterogeneity degree" between regions based on their historical traffic regularities.

  • Traffic-level: It masks less relevant traffic volumes to make the model robust against noise.
  • Topology-level: It adaptively removes edges between adjacent regions with dissimilar patterns and adds edges between distant regions that share similar urban functions (e.g., connecting two distant transportation hubs).

3. Dual SSL Auxiliary Tasks

The core innovation lies in two auxiliary tasks that run alongside the main prediction task:

  • Spatial SSL (Soft Clustering): The model maps regions into multiple latent representation spaces corresponding to urban functionalities. A clustering-based generative task encourages the model to recognize regions with similar roles.
  • Temporal SSL (Contrastive Learning): This task treats region-level and city-level embeddings from the same time step as "positive pairs" and those from different time steps as "negative pairs." This forces the model to distinguish between different temporal modes (e.g., rush hour vs. midnight).
Figure 2: (a): The overall architecture of ST-SSL. (b): Spatial heterogeneity modeling. (c): Temporal heterogeneity modeling.

Datasets

The model was evaluated on four diverse, real-world datasets:

  • NYCBike1 & NYCBike2: Bike rental records in New York City, measured every 30-60 minutes.
  • NYCTaxi: Taxi GPS trajectories in New York City.
  • BJTaxi: Taxi GPS trajectories in Beijing, measured on an hourly basis.

These datasets provide a mix of different transport modes, cities, and temporal resolutions to test the model's robustness.

Key Insights and Ideas

  • Adaptive > Random: The ablation studies proved that "heterogeneity-guided" augmentation is superior to random masking. By intelligently choosing which data to perturb, the model learns more meaningful representations of urban dynamics.
  • Global Context via Virtual Edges: By adding edges between non-adjacent but functionally similar regions during augmentation, the model can "transfer" knowledge across the city. This is why it performs so well in suburban areas where local data might be sparse.
  • Self-Supervision as a Regularizer: The auxiliary tasks act as powerful regularizers. The spatial clustering prevents the model from being overwhelmed by high-volume regions, while the temporal contrastive task helps it handle the data sparsity typical of nighttime periods.

Key Results

ST-SSL consistently outperformed eight baselines, including popular models like AGCRN and STGCN, across all datasets.

  • Quantitative: On the BJTaxi dataset, ST-SSL achieved a Mean Average Error (MAE) of 11.31 for inflow, compared to 12.30 for the next best baseline (AGCRN).
  • Qualitative: Visualization of prediction errors showed that ST-SSL significantly reduces errors in suburban areas (the "green boxes" in the paper's error maps).
  • Representation Quality: t-SNE visualizations of the learned embeddings showed that ST-SSL produces much tighter, more distinct clusters of similar regions compared to its competitors, confirming that it successfully captures urban functionality.

Limitations and Future Work

While highly effective, the paper notes a few areas for growth:

  • Model Agnosticism: The current SSL framework is built on a specific spatio-temporal convolutional backbone. The authors suggest that future work could involve making this SSL paradigm "model-agnostic" so it can be plugged into any architecture (like Transformers).
  • External Data: The current model relies purely on traffic flow data. Incorporating external factors like weather, special events, or Points of Interest (POI) data could further refine the spatial clustering and temporal contrastive tasks.

Summary updated

BibTeX
@inproceedings{ji2023spatio,
  author = {Jiahao Ji and Jingyuan Wang and Chao Huang and Junjie Wu and Boren Xu and Zhenhe Wu and Junbo Zhang and Yu Zheng},
  title = {{Spatio-Temporal Self-Supervised Learning for Traffic Flow Prediction}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i4.25555},
}
Figure