Large traffic networks experience a large volume of data and require predictions of the future traffic states based on current and historical traffic data. The traffic data are usually obtained by magnetic induction loop detectors mounted on road segments. These data include traffic speed and flow, where the term traffic flow is used interchangeably with the terms traffic volume and traffic counts. Machine learning approaches have recently been applied to traffic prediction tasks due to the massive volume of traffic data that has become available. The sequence of traffic data on each road segment is essentially a time series. However, each time series pertaining to each road segment has a spatial relationship with each other. Capturing the spatio-temporal patterns of the vehicular traffic is an important task and is part of the control of traffic networks.
Preliminary results on traffic forecasting with convolutional neural networks (CNNs) have been reported[1, 2]
. They have been demonstrated to be effective in understanding spatial features. Successive convolutional layers followed by max pooling operations increase the field of view of high-level layers and allow them to capture high-order features of the input data. Recurrent neural networks (RNNs) have also been incorporated, considering the traffic prediction as a time series forecasting. Different gating mechanisms like long short-term memories (LSTMs)[2, 3]
and gated recurrent unit (GRU) have been tested with various architecture. Instead of dealing with spatial features and temporal features separately, a novel approach has been proposed in  where the traffic data are converted into spatio-temporal images that are fed into a CNN. The deep neural network captures the spatio-temporal characteristics by learning the images. Recently, a capsule network (CapsNet) architecture proposed in  has been demonstrated to outperform the state-of-the-art in complex road networks. The dynamic routing algorithm of the CapsNet replaces the max pooling operation of the CNN, resulting in more accurate predictions but more parameters to train. Gaussian process (GP)  approach is another data-driven approach considered as a kernel-based learning algorithm. GPs have been repeatedly demonstrated to be powerful in exploring the implicit relationship between data to predict the value for an unseen point. Although comparative studies [8, 9] have shown that GPs are effective in short-term traffic prediction, they still suffer from cubic time complexity in the size of training data.
Inspired by ideas from [10, 11], this paper develops a structural RNN (SRNN) for traffic speed prediction, by incorporating the topological information into the sequence learning capability of RNNs. Considering each road segments as a node, the spatio-temporal relationship is represented by spatial edges and temporal edges. All the nodes and edges are associated with RNNs that are jointly trained. A computationally efficient SRNN is implemented in this paper and the performance is evaluated with real data.
The remaining of the paper is organized as follows. Section 2 describes the traffic speed prediction problem of interest. Section 3 validates the performance of the proposed approach. Finally, Section 4 concludes the paper.
2 Traffic Speed Prediction
2.1 Problem Formulation
In this study, we address the problem of short-term traffic speed prediction based on historical traffic speed data and a road network graph. Suppose we deal with road segments where the loop detectors are installed. Let represent the traffic speed on road segment at time step . Given a sequence of traffic speed data for road segments at time steps , we predict the future traffic speed on each road segment where denotes the current time step and denotes the length of data sequence under consideration.
2.2 Spatio-Temporal Graph Representation
We use a spatio-temporal graph representation as in [10, 11]. Let denote the spatio-temporal graph. , , and denote the set of nodes, the set of spatial edges, and the set of temporal edges, respectively.
. The edges are labelled with corresponding feature vectors.
In this study, the nodes in the graph correspond to road segments of interest. Thus, . The spatial edges represent the dynamics of traffic interaction between two adjacent road segments, and the temporal edges represent the dynamics of the temporal evolution of the traffic speed in road segments. Fig. 1(a) shows an example spatio-temporal graph. Nodes represent road segments. The connection between the road segments is represented by spatial edges . Note that our approach differs from  in that the spatial edges are established if the two road segments are connected, whereas 
employs an attention model on a fully-connected graph. In addition, we use two spatial edges in opposite direction to link neighbouring nodes. We attempt to take into account the directionality of the interaction between road segments. A temporal edge originated from nodeis pointing node . The spatial graph is unrolled over time using temporal edges to form as depicted in Fig. 1(b) where the edges are labelled with corresponding feature vectors.
The feature of node at time step is , denoting the traffic speed on the road segment. The feature vector of spatial edge at time step is , which is obtained by concatenating the features of nodes and as a row vector. Two spatial edges linking two nodes and in opposite direction have different feature vectors, e.g., and . The feature vector of temporal edge at time step is , which is obtained by concatenating the features of node at the previous time step and the current time step.
2.3 Model Architecture
In our architecture of the SRNN, the sets of nodes , spatial edges , and temporal edges are associated with RNNs denoted as nodeRNN , spatial edgeRNN , and temporal edgeRNN , respectively. The SRNN is derived from the factor graph representation . Our architecture is the simplest case where the nodes, spatial edges, and temporal edges are sharing the same factors, respectively. This means we assume the dynamics of spatio-temporal interactions is semantically same for all road segments, which keeps the overall parametrization compact and makes the architecture scalable with varying number of road segments. Readers interested in the factor graph representation can refer to .
Fig. 2 visualises the overall architecture. For each node , a sequence of node features is fed into the architecture. Every time each node feature enters, the SRNN is supposed to predict the node label , which corresponds to the traffic speed at the next time step . The input into the edgeRNNs is the edge feature of edge where the edge is incident to node in the spatio-temporal graph. The node feature is concatenated with the outputs of the edgeRNNs to be fed into the nodeRNN.
We use LSTMs for the RNNs. The hidden state of the nodeRNN has a dimension of 128, and that of the edgeRNNs has a dimension of 256. We employ embedding layers in the network that convert the input into an 128-dimensional vector with a rectified linear unit (ReLU) activation function to give nonlinearity.
3 Performance Validation
We use a traffic speed dataset from the case studies of the SETA EU project . Traffic speed measurements had been taken every 15 minutes in the central Santander city of Spain for the year of 2016. Each sparsely missing measurement is masked with an average of speed data recorded at the same time in the other days. We use data of the first 9 months as a training set and the remaining data of the last 3 months as an evaluation set.
We compare the performance of the proposed SRNN with the CapsNet architecture in  that outperforms the state-of-the-art with the dataset. These methods performed the following two speed prediction tasks:
Task 1: prediction based on 10-time-step data ()
Task 2: prediction based on 15-time-step data ()
for two different sets of road segments as depicted in Fig. 3. 50 road segments of interest, where the speed sensors are installed, are marked in red ().
3.2 Implementation Details
As one can see from Fig. 3, the road segments of interest are located sparsely. For constructing the spatial graph in the proposed architecture, we consider road segments adjacent to if they have the shortest distance to segment
. Here, the distance means the number of links traversed from a node to another. Our model has been developed based on the Pytorch implementation of.
The proposed architecture and the CapsNet in 
are given their best settings. Our network is trained with a batch size of 8, a starting learning rate of 0.001, and an exponential decay rate of 0.99. The CapsNet is trained with a batch size of 10, a starting learning rate of 0.0005, and an exponential decay rate of 0.9999. Both networks employ the mean squared error (MSE) as a loss function and the Adam optimizer. The traffic speed data, measured in , are scaled into the range before fed into the networks.
3.3 Performance Metrics
Statistical performance metrics are required to validate the overall performance of the networks. The mean relative error (MRE) is one of the most common metrics to quantify the accuracy of different prediction models in general. However, the error of a larger value of speed might result in a smaller MRE and vice versa, providing inconsistent results as witnessed in . Thus, we employ mean absolute error (MAE) and root mean squared error (RMSE) as more intuitive metrics for assessing the speed prediction performance. These performance metrics are defined as:
where and denote the speed prediction on road segment at time step and its true value, respectively. Here, denotes the set of time steps in the evaluation set, and represents the number of the speed data in the evaluation set.
Table 1 shows the resultant performance of the neural networks on the two tasks. The best performance out of 20 epochs is obtained for each method. The result indicates the SRNN performs slightly better byin RMSE, showing mere performance difference between methods and between tasks. The distinguishable difference resides in the number of trainable parameters which is translated into computational burden. The number of trainable parameters of the CapsNet varies from (Task 1) to (Task 2). Meanwhile, the number of trainable parameters of the SRNN is , which is independent of the sequence length . In fact, the size of the trainable parameter set of the SRNN is affected only by the size of the RNNs. The image-based approaches [5, 6] would face a significant increase in the computation time as the sequence length and the number of road segments increase. On the other hand, the SRNN is scalable to varying and , and can learn the spatio-temporal traffic characteristic with much fewer parameters given the topological information.
This paper presents a SRNN architecture that combines the road network map with the traffic speed data to make predictions of future traffic speed. The proposed architecture captures the spatio-temporal relationship of the traffic data with much fewer parameters compared with the image-based state-of-the-art methods.
Existing methods generally provide predictions on road segments where the traffic history is available. Our future work will focus on predictions in road networks with sparse data.
Y. Lv, Y. Duan, W. Kang, Z. Li, and F.-Y. Wang, “Traffic flow prediction with big data: A deep learning approach,”IEEE Transactions on Intelligent Transportation Systems, vol. 16, no. 2, pp. 865–873, 2015.
-  J. Zhang, Y. Zheng, and D. Qi, “Deep spatio-temporal residual networks for citywide crowd flows prediction,” in Proceedings of the AAAI Conference on Aritificial Intelligence, 2017, pp. 1655–1661.
-  X. Ma, H. Yu, Y. Wang, and Y. Wang, “Large-scale transportation network congestion evolution prediction using deep learning theory,” PloS one, vol. 10, no. 3, pp. 1–17, 2015.
-  Y. Wu, H. Tan, L. Qin, B. Ran, and Z. Jiang, “A hybrid deep learning based traffic flow prediction method and its understanding,” Transportation Research Part C: Emerging Technologies, vol. 90, pp. 166–180, 2018.
-  X. Ma, Z. Dai, Z. He, J. Ma, Y. Wang, and Y. Wang, “Learning traffic as images: a deep convolutional neural network for large-scale transportation network speed prediction,” Sensors, vol. 17, no. 4, p. 818, 2017.
-  Y. Kim, P. Wang, Y. Zhu, and L. Mihaylova, “A capsule network for traffic speed prediction in complex road networks,” in Proceedings of the Symposium Sensor Data Fusion: Trends, Solutions, and Applications, 2018, Conference Proceedings.
-  P. Wang, Y. Kim, L. Vaci, H. Yang, and L. Mihaylova, “Short-term traffic prediction with vicinity gaussian process in the presence of missing data,” in Proceedings of the Symposium Sensor Data Fusion: Trends, Solutions, and Applications, 2018, Conference Proceedings.
-  Y. Xie, K. Zhao, Y. Sun, and D. Chen, “Gaussian processes for short-term traffic volume forecasting,” Transportation Research Record, vol. 2165, no. 1, pp. 69–78, 2010.
-  J. Chen, K. H. Low, Y. Yao, and P. Jaillet, “Gaussian process decentralized data fusion and active sensing for spatiotemporal traffic modeling and prediction in mobility-on-demand systems,” IEEE Transactions on Automation Science and Engineering, vol. 12, no. 3, pp. 901–921, 2015.
-  A. Jain, A. R. Zamir, S. Savarese, and A. Saxena, “Structural-rnn: Deep learning on spatio-temporal graphs,” in
-  A. Vemula, K. Muelling, and J. Oh, “Social attention: Modeling attention in human crowds,” in Proceedings of the International Conference on Robotics and Automation. IEEE, 2018, Conference Proceedings, pp. 1–7.
-  F. R. Kschischang, B. J. Frey, and H.-A. Loeliger, “Factor graphs and the sum-product algorithm,” IEEE Transactions on information theory, vol. 47, no. 2, pp. 498–519, 2001.
-  SETA EU Project, A ubiquitous data and service ecosystem for better metropolitan mobility, Horizon 2020 Programme, 2016. Available: http://setamobility.weebly.com/.
-  D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” arXiv preprint arXiv:1412.6980, 2014.