{'fraction_non_alphanumeric': 0.035393985899956834, 'fraction_numerical': 0.009160232123159561, 'mean_word_length': 4.61897062786311, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Bayesian Spatio-Temporal Graph Convolutional Network for Traffic Forecasting

In traffic forecasting, graph convolutional networks (GCNs), which model traffic flows as spatio-temporal graphs, have achieved remarkable performance. However, existing GCN-based methods heuristically define the graph structure as the physical topology of the road network, ignoring potential dependence of the graph structure over traffic data. And the defined graph structure is deterministic, which lacks investigation of uncertainty. In this paper, we propose a Bayesian Spatio-Temporal Graph Convolutional Network (BSTGCN) for traffic prediction. The graph structure in our network is learned from the physical topology of the road network and traffic data in an end-to-end manner, which discovers a more accurate description of the relationship among traffic flows. Moreover, a parametric generative model is proposed to represent the graph structure, which enhances the generalization capability of GCNs. We verify the effectiveness of our method on two real-world datasets, and the experimental results demonstrate that BSTGCN attains superior performance compared with state-of-the-art methods.


Introduction
Traffic congestion is a growing drain on the economy with the acceleration of urbanization. For example, the cost of traffic congestion in America reached $124 billion in 2014, and will rise to $186 billion in 2030, according to a report by Forbes [1]. Therefore, improving traffic conditions is essential for increasing city efficiency, improving economy, and easing people's daily life. One promising way to mitigate urban traffic congestion is to introduce Intelligent Transportation Systems (ITS), in which traffic prediction plays a vital role. However, accurate traffic prediction is still challenging due to the complex spatio-temporal dependence among traffic flows.
In the past few decades, many schemes have been proposed for traffic prediction, which can be broadly divided into two categories: temporal dependence based methods and spatio-temporal dependence based methods. Temporal dependence based methods leverage temporal characteristics of traffic flows to predict future traffic condition. Nevertheless, these methods have limited capability to achieve Copyright © 2021, Association for the Advancement of Artificial Intelligence (www.aaai.org). All rights reserved. accurate traffic prediction due to ignoring the spatial dependence among traffic flows. Therefore, spatio-temporal dependence based methods are increasingly emerging, which take the spatial information into account. Since the road network is naturally structured as a graph in a non-Euclidean space with roads as nodes and their natural connections as edges, researchers prefer to use graph convolutional networks (GCNs) [2] to model spatial dependence among traffic flows instead of convolutional neural networks (CNNs).
However, existing GCN-based methods have two main disadvantages in terms of the graph construction: (1) The graph structure employed in GCNs is heuristically predefined and represents only the physical structure of the road network. Thereby, it is not guaranteed to be optimal description of dependence among traffic flows. For example, the relationship between two traffic flows that have similar trends but are located far away from each other is also important for traffic prediction. However, such dependence cannot be captured in the predefined road-topology-based graphs. (2) Introducing uncertainty into the graph structure, such as randomly dropping nodes or edges, could enhance the generalization capability of GCNs. Nevertheless, the graph structure employed in existing GCN-based methods is deterministic, which is lack of uncertainty investigation.
To solve above issues, a Bayesian Spatio-Temporal Graph Convolutional Network (BSTGCN) is proposed in this paper. It views the graph structure as a sample drawn from a parametric generative model, and aims to infer the posterior probability of the graph structure based on two types of information. One type is the physical topology of the road network, the other type is traffic data. In addition, parameters of the generative model are optimized together with weights of GCNs by the back-propagation algorithm in an end-to-end manner. The main contributions of our work lie in three folds: • This work proposes to learn the graph structure from the physical topology of the road network and traffic data in an end-to-end manner, which can find a more accurate descriptor of the relationship among traffic flows.
• A generative model is proposed to represent the graph structure, which can improve the generalization capability of GCNs.
• We validate the effectiveness of our method on two real-world datasets, and the experimental results show that our approach outperforms state-of-the-art methods by a noticeable margin.
The rest of the paper is organized as follows. Section 2 reviews research works related to traffic prediction. Section 3, 4, and 5 introduce the background, details of our method, and experimental results, respectively. Section 6 concludes this paper and points out some future directions.

Related Work
Traffic prediction has attracted a lot of attention in recent years due to its essential role in traffic management. Current methods generally have two categories, temporal dependence based methods, and spatio-temporal dependence based methods. Temporal dependence based methods only consider the temporal characteristics of traffic flows for traffic prediction. At the early stage, auto-regressive models including Auto-Regressive Integrated Moving Average (ARIMA) [3], Kalman filtering model [4], and seasonal ARIMA [5] are widely used in traffic prediction. However, these statistical models rely on the stationary assumption on traffic time series data, which hinders their performance on real-world traffic conditions that vary over time. Some traditional machine learning methods including Linear SVR [6], and random forest regression [7] are also tailored to solve traffic prediction, but are limited by hand-crafted features and shallow architectures. With the rapid development of deep learning, a variety of neural network architectures are applied in traffic prediction, such as the Feed Forward Neural network [8], LSTM and GRU [9]. Despite their impressive capability in modeling temporal dynamics, these methods still have limited ability to achieve accurate traffic prediction due to lacking consideration of the spatial dependence among traffic flows.
Spatio-temporal dependence based methods take temporal nature and spatial dependence of traffic flows into account for traffic prediction. To capture the spatial dependence among traffic flows, early attempts including SAE [10], ST-ResNet [11], and SRCN [12] have tried to employ various CNNs. Nevertheless, considering that CNNs prefer to Euclidean data [13], such as images, regular grids, and so on, such methods can not perform well in the road network with complex topological structure. As a result, a temporal graph convolutional network (T-GCN) [14] is proposed for traffic prediction, where GCNs and GRUs are combined to capture spatio-temporal features of traffic flows. Later, A3T-GCN [15] boosts the performance of T-GCN through introducing an attention mechanism. However, existing GCN-based works ignore the uncertainty and the information of traffic flows in the process of graph construction.

Background Graph Convolutional Network
GCNs have been widely applied to a broad of applications, such as semi-supervised learning [16], action recognition [17], and quality assessment [18]. Graph convolutional operation can be designed in either spatial or spectral domain. In this paper, we focus on the latter. Spectral convolution on graph G with N nodes is defined as the product of a signal X ∈ R N ×n (each node with a n-dim feature) and a filter g θ (L) parameterized by θ, i.e.: where U is the eigenvector of normalized Laplacian matrix L, and U T X is the Fourier transform of X. Since the Fourier transform is computationally expensive, a faster propagation rule [2] is proposed, i.e.: where H (l) and W (l) are the output feature and trainable parameters of the layer l, σ denotes the activation function, and H (0) equals X. The normalized adjacency matrix A is equal to D − 1 2 A D − 1 2 , where A and D are the adjacency matrix and the degree matrix of G. To include self-loop information, Eq. 2 is rewritten as: where A = A + I N , and I N is the identity matrix.

Bayesian Graph Convolutional Network
BGCN [19] is firstly introduced in the task of semisupervised node classification. In this task, we have an observed graph G obs = (V, E), where V and E denote the set of N nodes and edges. And we obtain feature vectors of all nodes X = {x 1 , ..., x N }, but only know labels of a portion of nodes Y L = {y 1 , ..., y n }. Then, we aim to infer the labels of the remaining nodes based on G obs , X and Y L . In the BGCN based framework viewing the graph structure and the weights of GCNs as random variables, the goal is to infer the posterior probability of labels Z, i.e.: where λ parameterizes random graphs and the term p(Z|W, G, X) is modeled by a categorical distribution. However, this formula ignores any possible dependence of the graph G on data as it targets the inference of p(G|G obs ).
To this end, an enhanced BGCN [20] is proposed, and formulates the posterior predictive distribution as follows: where the item p(G|G obs , X, Y L ) allows us to introduce the information of data. Additionally, as the integral in Eq. 5 is intractable, a Monte Carlo approximation [21] is often involved as follows: where C graphs G c sampled from p(G|G obs , X, Y L ) and S weights samples W s,c drawn from p(W |Y L , X, G). Considering that sampling graph from the posterior probability of G is time consuming, the maximum a posterior (MAP) inference of G is introduced as follows: As a result, Eq. 6 can be simplified as follows: where S weights samples W s obtained via dropout.

Method Problem Formulation
In the task of traffic prediction, we have access to the topology of the road network G obs = (V, E), where V is the set of N roads and E denotes the set of edges. And we also obtain historical traffic data on roads X 1: where X t belongs to R N ×n , and n is the dimension of traffic data. Then, our goal is to forecast T future signals X t+1:t+T based on G obs and X 1:t in an iterative manner. In other words, to predict X t+T , we take observed signals X 1:t and previous estimated results X t+1:t+T −1 as the input. It is worth noting that the traffic data on roads only includes the traffic speed in this paper, i.e., n is set to 1.
In general, traffic prediction is regarded as a task of learning a non-linear mapping function F which maps historical traffic data and the topology of the road network into traffic conditions in the future timestamps. Mathematically, we formulate the objective of traffic prediction as follows: where Y t+i is the ground truth at time t + i, and i is the desirable horizon ahead of the current timestamp t. In this paper, we propose a novel Bayesian spatio-temporal graph convolutional network (BSTGCN) to model F . As shown in Figure 1, four modules are involved in the BSTGCN, including a projection module, a spatio-temporal context module, a decoder module, and a Bayesian inference module. Next, we will detail these modules in sequence.

Projection Module
The projection module is designed to project 1D traffic speed of each road into a high-dimensional feature space using a linear layer. Concretely, the traffic speed of N roads at time t, X t ∈ R N ×1 , is transformed into 64-dim traffic features L t ∈ R N ×64 as follows: where the function f (·) consists of a fully-connected (FC) layer with 64 neurons, and the enhanced representation of traffic speed L t is beneficial to learn the spatio-temporal characteristics of traffic flows.

Spatio-temporal Context Module
As aforementioned, the future traffic speed of one road not only depends on the historical traffic speed of the road, but also is constrained to the physical topology of the road network. As a result, the spatio-temporal context module is proposed to capture the spatio-temporal features for each road.
In the light of the good performance of Gate Recurrent Unit (GRU) [22] in modeling temporal characteristics of sequential data [23], we tailor the original GRU for dealing with graph-structured traffic data. In particular, we sequentially feed the input sequence L 1:t into the tailored GRU, and denote the output of the tailored GRU at timestamp t + 1 as: where the function h(·) is comprised of a tailored GRU with the hidden size of 64, and the input-state transitions of the tailored GRU are expressed as follows: where H t+1 , r t+1 , z t+1 , and n t+1 are the hidden state, the reset, update, and new gates at time t + 1, respectively. σ is the sigmoid function, denotes the graph convolutional operation, and means the Hadamard product. W u , W r , W c , b u , b r , and b c are trainable parameters. As seen in Eq. 12, the tailored GRU replaces FC layers in the conventional GRU with GCNs, which could learn the spatial characteristics of traffic flows. Moreover, we introduce uncertainty and the information of traffic data to the graph structure employed in GCNs, which is detailed in the part of the Bayesian inference module.

Decoder Module
The decoder module aims to map the spatio-temporal feature H t+1 into the traffic speed of roads at time t+1 with a linear layer, which is formulated as follows: where the function z(·) is made up of a FC layer with 1 neuron.

Bayesian Inference Module
The Bayesian inference module is designed to discover better graph structure from the G obs , input data X = X 1:t , and corresponding label Y = Y t+1 , as well as introducing uncertainty into the graph structure. In this paper, we consider a Bayesian approach, viewing the graph structure as a sample drawn from a parametric generative model. We then aim to infer the posterior predictive distribution as follows: where W is the set of trainable parameters of our network, and Z = X t+1 is the ground-truth traffic speed at time t + 1. As seen in Eq. 14, the posterior probability of graph p(G|X, Y, G obs ) is calculated in a two-step manner, where the information of the topology of the road network G obs and the information of traffic data (X, Y) are successively introduced into the graph structure G. The specific calculation of Eq. 14 is presented as follows. Since there is no closed-form solution for the integral in Eq. 14, a Monte Carlo approximation is introduced as follows: sample the graph structure G from Aĝ +φ via dropout 7: sample a batch of data {X 1:t , Y t+1:t+T } from D 8: for i = 1 to T do 9: obtain predicted result X t+i at time i 10: end for 11: optimize W and φ by minimizing Eq. 9 12: end for where C graphs g c sampled from p(g|G obs ), S weights samples G s,c drawn from p(G|g c , X, Y), and p(Z|X, W, G s,c ) is modeled by a Gaussian likelihood. Like the improved BGCN [20], we replace the integral over g with a MAP process, as follows:ĝ = arg max g p(g|G obs ).
As described in the work [20], solving Eq. 16 is equivalent to learning a N × N symmetric adjacency matrix of g, expressed as follows: where α and β control the scale and density of Aĝ. Here, Z is the pairwise distance of roads in the embedding space, which is calculated as follows: where e p and e q are the embedding vector of the p-th and qth road. In this paper, we learn embedding vectors of roads through the Graph Variational Auto-Encoder algorithm [24]. After obtaining Z, we solve the Eq. 17 via the prevalent method [25]. As for the inference of p(G|g, X, Y), we also adopt a Monte Carlo approximation. Thus, Eq. 14 is rewritten as follows: where S weights samples G s drawn from Aĝ +φ via dropout, and φ ∈ R N ×N is a trainable deterministic variable that allows us to introduce the information of traffic data into the graph structure. As we can see, φ aims to learn the global graph structure as it is shared across all timestamps. The training algorithm of φ is described in Algorithm 1.

Relationship with Existing BGCNs
The improved BGCN [20] cannot be applied in traffic prediction due to two main reasons: (1) To include the information of traffic data in the graph structure, it needs to pre-calculate the MAP resultĜ for each timestamp, which is time-consuming. (2) It relies on the assumption that the graph structure is symmetric in the calculation ofĜ. However, this hypothesis is easily violated in the task of traffic prediction because the mutual influence of two traffic flows is usually unequal. In our proposed method, we learn the dependence of the graph structure over traffic data by injecting a trainable parameter φ, without introducing extra calculation. Moreover, the learned graph structure Aĝ + φ can be either symmetric or asymmetric.

Implement Details
We implement BSTGCN on the PyTorch framework [28]. All trainable variables in BSTGCN are optimized by the Adam [29] optimizer. We train BSTGCN on a NVIDIA Geforce GTX 1080Ti GPU for 100 epochs. The learning rate is initialized as 10 −2 and 10 −3 for the SZ-taxi and Losloop dataset, respectively. During training, 32 pairs are randomly generated from the training dataset per iteration, and the learning rate is decayed by 0.2 every 25 epochs. It is worth noting that we use the learned graph structure without dropout in the evaluation phase.

Parameter Experiment and Ablation Study
First, we investigate the impact of hidden size and Monte Carlo dropout probability on the prediction performance in Table 1 and 2. As we can see, the prediction performance with 64 hidden neurons achieves the optimum on two realworld datasets. And, the optimal configurations of Monte Carlo dropout probability are 0.1 and 0.5 for the SZ-taxi and Los-loop dataset. As a result, we fix these hyperparameters in the following experiment.
Second, we verify the importance of introducing uncertainty and different ways of learning the graph structure in Table 3. B c and B d are two variants of BSTGCN. B a and B b learn the individual traffic pattern for each timestamp through Graph Attention Network [30] and Self-Attention Network [31], but ignore the uncertainty. According to results of B c , B d , and BSTGCN, we can conclude that introducing uncertainty and the information of traffic data into the graph structure can steadily improve the performance of traffic prediction. In addition, we can see that B c that learns the global traffic pattern across all timestamps exceeds B a and B b by a clear margin, which confirms the advantage of our way to learn graph structure from traffic data.     Visualized Results of Graph Structure Figure 2 visualizes the observed adjacency matrix A G obs , the MAP estimation of adjacency matrix Aĝ, and the final learned adjacency matrix A G . We can see that A G has the densest connectivity among traffic flows, but is of an asymmetric structure. This confirms that the assumption that adjacency matrix is symmetric is violated in the task of traffic prediction. In addition, we can notice that the relationships among traffic flows in A G are not always positive. However, such negative dependence among traffic flows cannot be captured in the original observed adjacency matrix A G obs .   Figure 3 presents the prediction results of BSTGCN in the setting of 15-, 30-, and 45-minute prediction horizon. First, we can see that the traffic speed in the SZ-taxi dataset is more stationary than that of the Los-loop dataset. This explains the phenomenon that the naive historical average model (HA) performs well in the SZ-taxi dataset. Second, we can notice that the prediction results of BSTGCN are closer to the ground-truth traffic speed than that of existing methods, which is more obvious in the long-term prediction. This confirms the excellent ability of BSTGCN in traffic forecasting. Third, despite achieving impressive results, BSTGCN still cannot predict the value of sharply changing points.

Deep Dive into Network Architecture
We also have a deep dive into the network architecture of BSTGCN. Specifically, we switch the activation function of the reset gate in the tailored GRU from the sigmoid function to the identity function. The experimental results are presented in Table 5. It is interesting that such a simple modification can bring a noticeable gain in the Los-loop dataset, but has little impact in the SZ-taxi dataset. This phenomenon indicates different datasets prefer to different neural architecture. As a result, we advocate that automatically search neural architecture for the specific dataset is a promising alternative to further improve the performance of BSTGCN.