How to Predict Traffic Flow with H-STFormer

Traffic flow prediction is a crucial task for intelligent transportation systems. It can help us plan our trips, avoid traffic jams, and improve road safety. But predicting traffic flow takes work. Traffic flow data are complex and dynamic, depending on spatial and temporal factors. For example, the traffic flow at a specific location may change according to the time of day, the day of the week, the weather, and the events happening nearby. Moreover, the traffic flow at different locations may influence each other, especially if transport hubs like airports, train stations, or bus terminals connect them.

To tackle these challenges, a team of researchers from South Korea proposed a novel model called Transport-Hub-aware Spatial-Temporal adaptive graph transFormer (H-STFormer) for traffic flow prediction. The model uses graph neural networks and transformers to capture traffic flow data’s spatial and temporal dependencies. The model also considers transport hub information to enhance the spatial self-attention mechanism, which can highlight both short- and long-term spatial correlations.

The researchers tested their model on two real-world datasets: PeMSD7 and PeMSD4. The results showed that H-STFormer performed better than the state-of-the-art methods regarding mean absolute error (MAE) and root mean squared error (RMSE). The researchers also conducted ablation studies to verify the effectiveness of each component of their model. Furthermore, the researchers designed an extra module for incremental learning of traffic flow prediction tasks, which can adapt to new data without forgetting previous knowledge.

The paper was submitted to arXiv on October 12, 2023, by Xiao Xu, Lei Zhang, Bailong Liu, Zhizhen Liang, and Xuefei Zhang. The paper has yet to be peer-reviewed. The code is available at this URL.

The paper contributes to traffic flow prediction by proposing a novel model that can capture both spatial and temporal dependencies in traffic flow data and transport hub information. The paper also demonstrates the feasibility of incremental learning for traffic flow prediction tasks. The paper has potential applications in various transportation-related domains, such as traffic management, route planning, congestion control, and emergency response. The paper may inspire future research on spatial-temporal data mining and graph neural networks.

This article will explain how the H-STFormer model works and why it is better than previous methods. We will also show how the model can predict traffic flow in different scenarios. Let’s dive in!

H-STFormer is based on two key concepts: graph neural networks and transformers. Graph neural networks are neural networks that can handle graph-structured data, such as road networks. Transformers are neural networks that can handle sequential data, such as time series. Combining these two concepts allows H-STFormer to capture spatial and temporal dependencies in traffic flow data.

H-STFormer consists of three main components: a spatial-temporal data embedding layer, a hub-aware spatial-temporal adaptive graph transformer with stacked encoder blocks, and a knowledge distillation module for incremental learning.

The spatial-temporal data embedding layer converts the input into a higher-dimensional representation through a fully connected layer. It also incorporates spatial and temporal information into the representation.

The spatial information includes the road network structure and the transport hub information. The graph Laplacian eigenvectors represent the road network structure, which describes the distance between nodes on the graph better. The transport hub information is derived from the degree and weight of each node and edge on the graph, which indicates the importance and status of each road segment and sensor node.

The temporal information includes the time slices in a day and day in a week signals, which capture the short- and long-term periodicity of traffic flow data. It also consists of the temporal position embedding, which captures the relative position information of each time slice.

The hub-aware spatial-temporal adaptive graph transformer consists of stacked encoder blocks that process the embedded data. Each encoder block contains four heterogeneous self-attention modules: hub-aware spatial self-attention (HubSSA), geographic spatial self-attention (GeoSSA), semantic spatial self-attention (SemSSA), and temporal self-attention (TSA).

HubSSA captures the potential transport hubs in the road network by using a hub-aware masking matrix that assigns higher weights to nodes and edges with higher degrees and weights. This way, HubSSA can highlight short- and long-term spatial correlations among nodes.

GeoSSA captures the geographic neighborhoods among nodes by using a geographic masking matrix that filters out node pairs that are geographically far away from each other. This way, GeoSSA can focus on local spatial dependencies among nodes.

SemSSA captures the semantic neighborhoods among nodes using a semantic masking matrix that filters out node pairs with different traffic patterns. This way, SemSSA can focus on similar spatial dependencies among nodes.

TSA captures the dynamic temporal patterns among time slices using a temporal self-attention mechanism with a global receptive field. This way, TSA can capture long-range temporal dependencies among time slices.

The outputs of these four self-attention modules are fused by a heterogeneous attention fusion module, which concatenates and projects them into a unified representation. The fusion module also applies layer normalization and residual connection to enhance the stability and performance of the model.

The knowledge distillation module for incremental learning enables the model to adapt to new data without forgetting previous knowledge. It uses a student-teacher learning framework, where the old model acts as the teacher, and the new model serves as the student.

The knowledge distillation module first splits the data into two sets: the transfer set and the incremental set. The transfer set contains data from the previous time duration, while the total set contains data from the new time duration. The module then uses the old model to predict the traffic flow on both sets and uses the latest model to do the same. The module then optimizes the new model with a distillation loss, which measures the difference between the predictions of the old and new models.

The knowledge distillation module also uses a data exchanging strategy, which swaps the transfer and incremental data set for retraining. This way, the module can expose both models to more data and enhance their discriminative ability.

H-STFormer is better than previous methods for traffic flow prediction for several reasons. First, it can effectively capture spatial and temporal dependencies in traffic flow data using graph neural networks and transformers. Second, it can incorporate transport hub information into the spatial self-attention mechanism, highlighting short- and long-term spatial correlations. Third, it can perform incremental learning of traffic flow prediction tasks using a knowledge distillation module that can adapt to new data without forgetting previous knowledge.

H-STFormer outperforms other state-of-the-art methods on two real-world datasets: PeMSD7 and PeMSD4. The results show that H-STFormer performs better than the baselines regarding mean absolute error (MAE) and root mean squared error (RMSE). H-STFormer also performs well on incremental learning tasks, showing it can handle dynamic traffic flow data.

H-STFormer can predict traffic flow in different scenarios, such as average days, holidays, weekdays, weekends, peak hours, off-peak hours, sunny days, rainy days, etc. Using its spatial-temporal adaptive graph transformer, H-STFormer can capture the dynamic spatial-temporal patterns in traffic flow data and adjust its predictions accordingly.

For example, H-STFormer can predict that traffic flow will be higher on holidays than on regular days, as more people tend to travel on holidays. H-STFormer can also expect traffic flow to increase more on weekdays than on weekends, as more people commute to work or school on weekdays. H-STFormer can also predict that traffic flow will expand more on peak than off-peak hours as more people drive during rush hours. H-STFormer can also expect traffic flow to be lower on rainy days than on sunny days, as rain may cause road hazards or delays.

H-STFormer can also predict how traffic flow will change at different locations, especially if transport hubs connect them. H-STFormer can highlight short- and long-term spatial correlations among nodes using its hub-aware spatial self-attention mechanism. For example, H-STFormer can predict that traffic flow will increase at a node near an airport if a flight arrives or departs. H-STFormer can also expect traffic flow to decrease at a node near a train station if there is a train delay or cancellation.

H-STFormer can also predict how traffic flow will be affected by external factors or events, such as accidents, road closures, festivals, concerts, sports games, etc. Using its semantic spatial self-attention mechanism, H-STFormer can focus on similar spatial dependencies among nodes. For example, H-STFormer can predict that traffic flow will decrease at a node near an accident site if there is a road blockage or diversion. H-STFormer can also expect traffic flow to increase at a node near a festival venue if there is a large crowd or attraction.

In this article, we have explained how H-STFormer works and why it is better than previous methods for traffic flow prediction. We have also shown examples of how H-STFormer can predict traffic flow in different scenarios. We hope you have enjoyed reading this article and learned something new about traffic flow prediction with H-STFormer.

If you want to learn more about H-STFormer or try it yourself, you can check out their paper.
2310.08328.pdf (arxiv.org)

Our vision is to lead the way in the age of Artificial Intelligence, fostering innovation through cutting-edge research and modern solutions. 

Quick Links
Contact

Phone:
+92 51 8912223

Email:
info@neurog.ai