Urban Traffic Flow Prediction Based on Spatio-Temporal Convolution Networks


Urban traffic flow prediction plays an important role in traffic flow control and urban safety risk prevention and control. Timely and accurate traffic flow prediction can provide guidance for traffic, relieve urban traffic travel pressure and reduce the frequency of accidents. Due to the randomness and fast changing speed of urban dynamic traffic data flow, most of the existing prediction methods lack the ability to model the dynamic temporal and spatial correlation of traffic data, so they cannot produce satisfactory prediction results. A spatio-temporal convolution network (ST-CNN) is proposed to solve the traffic flow prediction problem. The model consists of two parts: 1) a convolution block used to extract spatial features; 2) a block of time used to characterize time. Data has been fully mined through two modules to output the prediction results of spatio-temporal characteristics, and at the same time, skip connection (direct connection) has been made between the two modules to avoid the problem of gradient explosion. The experimental results on two data sets show that ST-CNN is better than the baseline model.

Share and Cite:

Zheng, P. , Li, Y. , Lin, M. and Hu, Y. (2023) Urban Traffic Flow Prediction Based on Spatio-Temporal Convolution Networks. Journal of Computer and Communications, 11, 15-23. doi: 10.4236/jcc.2023.113002.

1. Introduction

Advanced intelligent transportation system cannot be separated from basic traffic data processing [1] [2] . At present, there are a variety of data acquisition and processing methods in the field of intelligent transportation, which also provides multidimensional traffic data for ITS. How to effectively apply these data to ITS has become a hot research topic at present [3] [4] . Traffic flow prediction is a way of traffic data processing [5] [6] . Accurate traffic prediction information can provide a powerful basis for traffic decision making for traffic managers, and also enable drivers to choose a more smooth road to travel, so as to avoid or alleviate traffic congestion [7] [8] .

Traffic flow prediction is a typical spatio-temporal data prediction problem. Traffic data records the traffic flow, occupancy, speed, etc., at a fixed point in time at a fixed location. Obviously, the traffic flows observed at adjacent locations and time stamps are not independent of each other, and the traffic flow at the previous location will affect the traffic flow at the next node after a period of time, showing a strong temporal and spatial correlation [9] . At the same time, the traffic flow is also cyclical. For example, the morning and evening peak traffic flow on weekdays shows great similarity [10] . Figure 1 shows the traffic flow of a street in Chengdu for five consecutive working days. We can see the same trend in their traffic flow. How to explore complex spatiotemporal data to find its inherent spatiotemporal patterns and make accurate traffic flow prediction is a very challenging problem.

Fortunately, with the development of the transportation industry, many information collection devices have been deployed on urban roads. Each device has unique spatial GPS coordinates that continuously generate time series data about traffic. These devices have accumulated a large number of rich traffic time series data and geographic information, which provides a solid data basis for traffic prediction. Many researchers have made great efforts to solve these problems.

Earlier, time series analysis model was applied to traffic prediction problems. In practice, however, they do not work well with unstable and non-linear data. Later, traditional machine learning methods have been developed to model more complex data, but they are still difficult to consider the spatio-temporal correlation of high-dimensional traffic data at the same time. Moreover, the predictive

Figure 1. Traffic flow of No. 255 grid in Chengdu for five consecutive working days.

performance of these methods relies heavily on feature engineering and heavily on expertise. In recent years, many researchers have used deep learning methods to process high-dimensional spatio-temporal data, that is, convolutional neural networks (CNN) to effectively extract spatial features of grid-based data. However, these methods are still unable to simultaneously model the temporal and spatial characteristics and dynamic correlation of traffic data.

To address the above challenges, a new deep learning model, the spatio-temporal Convolutional Network (ST-CNN), is proposed in this paper to predict the traffic flow at each location on the traffic network. The model can capture dynamic temporal and spatial characteristics effectively. The main work of this paper is summarized as follows:

· In this paper, the map is divided into 30 * 30 grids for Chengdu and 32 * 32 grids for Beijing.

· In this paper, a spatiotemporal convolution module is designed, which mines information from adjacent grid blocks from the traffic network structure.

· Experiments on real-world highway traffic data sets show that our model has the best predictive performance compared with existing baseline models.

2. Related Work

Zhang [11] proposes a short-term traffic flow prediction model based on the deep learning framework of convolutional neural networks (CNN). The spatial-temporal feature selection algorithm (STFSA) is used to determine the optimal input data, extract the selected spatial-temporal traffic flow features from the actual data, and use CNN to learn these features to construct the prediction model. However, this model does not deal well with time characteristics. Zhao [12] proposes a CNN-LTSM model IL-TFNet based on incremental learning for traffic flow prediction. The K-means clustering algorithm is used as the uncertainty feature to extract unknown traffic accident information. The model can process the characteristics of time and space and external environment at the same time, ensuring the prediction accuracy of the model. Y. Tian [13] believes that the input of many current models is static, and uses three multiplication elements in memory block to dynamically determine the optimal time delay, and proposes a model called long and short term memory cyclic neural network (LSTM RNN).However, this model does not consider the dynamic temporal and spatial correlation of traffic data. Inspired by the above research, considering the spatial topology of traffic network and the dynamic spatio-temporal pattern of traffic data, we simultaneously use convolutional neural network and cyclic neural network to construct spatio-temporal feature extraction blocks to mine spatio-temporal information.

3. Preliminaries

3.1. Raster Data

Raster data is a data form that divides space into regular grids, each grid is called a cell, and assigns corresponding attribute values to each cell to represent entities. Figure 2 shows the specific method of raster partitioning.

3.2. Traffic Flow Forecasting

The task of traffic flow prediction is to learn a mapping relationship f for a given traffic network spatial graph G and multiple consecutive traffic flow data of the same time segment, and use this relationship to predict the traffic flow in the following continuous period of time. The mathematical definition of traffic flow prediction task is as follows:

( X t : t + T 1 , G ) f X t + T 1 : t + T 1 + T 2 (1)

where, the former represents the historical data required by the prediction model, the latter is the output of the model, and f is the traffic flow prediction model.

3.3. Evaluation

In this paper, root mean square error (MSE) and mean absolute error (MAE) are used to evaluate the performance of the model. The calculation formula is as follows:


RMSE = 1 N i = 1 n ( y i y ^ i ) 2 (2)


Figure 2. Raster division.

MAE = 1 n i = 1 n | y i y ^ i | (3)

4. Spatio-Temporal Convolution Networks

The proposed model is composed of Time-block and Spati-block. As shown in Figure 3, the Time-block is composed of two fully connected layers and a cyclic unit. The nonlinear characteristics of data can be learned to the maximum extent through the fusion of gated layers composed of three different activation functions. Spatil-Block consists of three convolution layers and one fully connected layer. Time-block blocks and Spati-block blocks together form ST-Block blocks. ST-block can fully extract the spatio-temporal characteristics of data, and skip connection is adopted to avoid gradient explosion problem. As shown in Figure 4, the predicted value is obtained through multiple St-blocks.

Figure 3. The structure of ST-CNN Model.

Figure 4. The process of ST-CNN model prediction.

5. Experiments

The experiment was carried out in Windows10 system, using Anaconda Navigator (Jupyter notebook) and Python3.7 as experimental platforms, and using the neural network model provided by pytorch framework to simulate the experiment.

5.1. Datasets

We tested our model on two highway traffic data sets: Chengdu taxi and Beijing taxi [10] . The details of the datasets are shown in Table 1.

· TaxiCD. The dataset collected more than 1.4 billion taxi GPS data from more than 14,000 taxis in Chengdu from 8/1, 2014 to 8/30, 2014.

· TaxiBJ. This data set is a taxi trajectory data set collected by Microsoft Research, including the trajectory of 10,357 taxis in Beijing during the week from February 02, 2008 to February 08, 2008.

5.2. Baseline

The baseline model we selected is shown in Table 2.

5.3. Comparison and Result Analysis

Using the early stop method for training, Table 2 shows how the different models perform on the two datasets.

It can be seen from Table 3 that the performance of HA model is at the bottom of the two data sets. This is because HA model is a traditional statistical method and it is difficult for it to learn the complex nonlinear relationship between data. RNN models outperform CNN on TaxiCD data sets, but CNN performs better on TaxiBJ data sets. This may be because Beijing’s traffic structure is more complex than Chengdu’s, so the TaxiBJ dataset contains more spatial structure information.

Table 1. Traffic flow dataset (Table caption is indispensable).

Table 2. Traffic flow dataset (Table caption is indispensable).

Table 3. Traffic flow dataset.

Table 4. Ablation experiment result.

5.4. Ablation Experiment

Cancel some modules and replace the Spati-block module with the full connection layer in ST-CNN_noCNN, and replace the Time-block module with the full connection layer in ST-CNN_noRNN. From Table 4, we can see that the experimental results are consistent with Table 3: ST-CNN_noCNN performs better in TaxiCD data set and ST-CNN_noRNN performs better in TaxiBJ data set. Moreover, ST-CNN performance is optimal on both data sets, which proves that Spati-block and Time-Block blocks play a role in improving model performance.

6. Conclusion and Future Work

In this paper, a new spatio-temporal convolution model ST-CNN is proposed and successfully applied to traffic flow prediction. The model combines cyclic neural networks and convolutional neural networks to capture dynamic spatio-temporal characteristics of traffic data. Experiments on two real-world data sets show that the prediction accuracy of the proposed model is better than that of the baseline model. There are still some shortcomings in this paper. For example, it does not consider the influence of weather factors on traffic flow. Sometimes there are similar traffic flow patterns in places that are far apart. For example, the traffic flow of two overpasses that are far apart is similar. This similarity is called semantic similarity.

Conflicts of Interest

The authors declare no conflicts of interest regarding the publication of this paper.


[1] Zheng, C., Fan, X., Wen, C., et al. (2019) DeepSTD: Mining Spatio-Temporal Disturbances of Multiple Context Factors for Citywide Traffic Flow Prediction. IEEE Transactions on Intelligent Transportation Systems, 1-12.
[2] Li, L.X., et al. (2020) MF-TCPV: A Machine Learning and Fuzzy Comprehensive Evaluation-Based Framework for Traffic Congestion Prediction and Visualization. IEEE Access, 8, 227113-227125.
[3] Mohammed, O. and Kianfar, J. (2018) A Machine Learning Approach to Short-Term Traffic Flow Prediction: A Case Study of Interstate 64 in Missouri. 2018 IEEE International Smart Cities Conference (ISC2), Kansas City, MO, 16-19 September 2018, 1-7.
[4] Zhu, H. and Shibata, T. (2012) A Real-Time Motion-Feature-Extraction VLSI Employing Digital-Pixel-Sensor-Based Parallel Architecture. IEEE Transactions on Circuits & Systems for Video Technology, 24, 1787-1799.
[5] Qin, G., et al. (2021) Traffic Flow Prediction Based on JANet and Attention Mechanism. 2021 6th International Conference on Intelligent Computing and Signal Processing (ICSP), Xi’an, 9-11 April 2021, 131-134.
[6] Essien, A.E., Chukwkelu, G. and Giannetti, C. (2019) A Scalable Deep Convolutional LSTM Neural Network for Large-Scale Urban Traffic Flow Prediction Using Recurrence Plots. 2019 IEEE AFRICON, Accra, 25-27 September 2019, 1-7.
[7] Jiang, C.Y., Hu, X.M. and Chen, W.N. (2021) An Urban Traffic Signal Control System Based on Traffic Flow Prediction. 2021 13th International Conference on Advanced Computational Intelligence (ICACI), Wanzhou, 14-16 May 2021, 259-265.
[8] Yang, W. (2020) Short-Term Traffic Prediction Based on Historical Trend Method. 2020 International Conference on Urban Engineering and Management Science (ICUEMS), Zhuhai, 24-26 April 2020, 438-441.
[9] Shi, Y., Feng, H., Geng, X., et al. (2019) A Survey of Hybrid Deep Learning Methods for Traffic Flow Prediction. Proceedings of the 2019 3rd International Conference on Advances in Image Processing, New York, 8-10 November 2019, 133-138.
[10] Zhang, J.B., Zheng, Y. and Qi, D.K. (2017) Deep Spatio-Temporal Residual Networks for Citywide Crowd Flows Prediction. Proceedings of the Thirty-First AAAI Conference on Artificial Intelligence (AAAI’17), 31, 1655-1661.
[11] Zhang, W.B., Yu, Y.H., Qi, Y., Shu, F. and Wang, Y.H. (2019) Short-Term Traffic Flow Prediction Based on Spatio-Temporal Analysis and CNN Deep Learning. Transportmetrica A: Transport Science, 15, 1688-1711.
[12] Hao, Y., Zhao, Y., Yu, F., et al. (2021) The Traffic Flow Prediction Method Using the Incremental Learning-Based CNN-LTSM Model: The Solution of Mobile Application. Mobile Information Systems, 2021, Article ID 5579451.
[13] Tian, Y. and Pan, L. (2015) Predicting Short-Term Traffic Flow by Long Short-Term Memory Recurrent Neural Network. 2015 IEEE International Conference on Smart City/SocialCom/SustainCom (SmartCity), Chengdu, 19-21 December 2015, 153-158.
[14] Zhou, Z. and Huang, K. (2008) Study of Traffic Flow Prediction Model at Intersection Based on R-FNN. 2008 International Seminar on Business and Information Management, Wuhan, 19-19 December 2008, 531-534.

Copyright © 2024 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.