How STFAN Revolutionizes Traffic Flow Forecasting with Spatio‑Temporal‑Frequency Attention

This article introduces the Spatio‑Temporal‑Frequency Attention Network (STFAN), a deep‑learning model that fuses graph neural networks, attention mechanisms, and frequency‑domain analysis to capture hidden spatial, temporal, and spectral dependencies in traffic data, achieving superior short‑ and long‑term forecasting performance on real‑world datasets.

Data Party THU
Data Party THU
Data Party THU
How STFAN Revolutionizes Traffic Flow Forecasting with Spatio‑Temporal‑Frequency Attention

Introduction

Intelligent transportation systems depend on accurate traffic flow forecasting. Existing approaches mainly exploit spatio‑temporal correlations in historical data while overlooking inherent frequency characteristics of traffic time series.

This work proposes a frequency‑domain traffic analysis method that integrates attention mechanisms to capture spatial, temporal, and frequency dependencies, resulting in the Spatio‑Temporal‑Frequency Attention Network (STFAN).

Problem Definition

The traffic network is modeled as an undirected graph G = (N, E, A), where N is the set of sensors, E the edges, and A the adjacency matrix. Each sensor records a feature vector X_i^t ∈ ℝ^C at time t. Given M historical observations, the goal is to predict traffic states for the next T steps.

Mathematical formulation of the forecasting task is illustrated in the following equations:

equation
equation

Model Architecture

STFAN consists of stacked spatial modules, spatio‑temporal‑frequency (STF) modules, and a prediction layer. Each STF module contains a spatial attention block and a time‑frequency attention block.

STFAN overall architecture
STFAN overall architecture

Spatial Attention Module

The spatial attention module combines an embedding layer, a graph convolutional network (GCN), a cross‑attention layer, and a gating mechanism. The embedding layer injects positional information for both graph topology and time steps. The GCN uses Chebyshev polynomial approximation to capture structural dependencies.

Spatial attention architecture
Spatial attention architecture

Time‑Frequency Attention Module

This module splits traffic features into temporal and frequency domains. The temporal attention block learns hidden relations across time steps using multi‑head self‑attention. The frequency attention block applies discrete Fourier transform (DFT) to extract amplitude and phase components, then uses attention to model hidden correlations in the frequency domain.

Time‑frequency attention architecture
Time‑frequency attention architecture

Prediction Layer

Two classic 1×1 convolutional layers map the fused spatio‑temporal‑frequency features to multi‑step forecasts. The model is trained with mean absolute error loss.

Prediction layer
Prediction layer

Experiments

STFAN was evaluated on the PeMS04 and PeMS08 datasets released by the California Department of Transportation. Compared with several baseline models, STFAN achieved significantly lower prediction errors, especially for medium‑ and long‑term horizons. Ablation studies demonstrated that frequency‑domain features contribute substantially to the model’s performance.

Conclusion

STFAN effectively integrates spatial topology, temporal dynamics, and frequency patterns to improve traffic flow prediction. The detailed experimental results, including performance comparison, module ablation, and hyper‑parameter analysis, will be presented in a follow‑up study.

graph neural networksTraffic Predictionfrequency analysisspatio-temporal attentionSTFAN
Data Party THU
Written by

Data Party THU

Official platform of Tsinghua Big Data Research Center, sharing the team's latest research, teaching updates, and big data news.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.