## 4 Social Media-Driven Traffic Prediction Framework with Illustrative Example
### Data Analysis and Prediction
#### 4.2.2 Traffic Prediction  
Two tools will be used to perform the traffic prediction with information collected from historical data and social network analysis: Graph Convolutional and Long-Short Term Memory Neural Networks. These duo have been used in literature for traffic conditions, flow, or speed prediction [18; 34; 39]. However, none include a complete set of weather factors and their interaction with social media networks or POIs.  
Graph Convolutional Neural Network (GCN)  
Unlike regular Convolutional Networks, GCNs can handle high-dimensional and non-Euclidean data. GCNs have vertices that send and receive messages to and from other vertices through edges, and at each vertex and layer, an aggregation function is performed. The number of convoluted layers determines the number of neighborhoods the message will travel through. The architecture of the network is represented in Figure 7.  
Figure 6: Example of COIN on Twitter with users interested in traffic within Los Angeles. Users are grouped in similarity clusters and the nodes are sized by influence (trendsetters).  
Figure 7: Graph convolutional network architecture.  
GCNs use forward propagation using an adjacency matrix to include graph information in the formula. Formula (1) belongs to forward propagation, where \(H^{(l+1)}\) represents the feature representation in layer \(l+1\), \(\sigma\) is the activation function, \(W^{l}\) is the weights for layer l, \(H^{l}\) is the feature vector for layer \(l\), and \(b^{l}\) represents the biases for layer \(l\). In contrast, Formula (2) is the adjusted formula for GCN:  
\[H^{(l+1)}=\sigma\Big{(}W^{l}H^{l}+b^{l}\Big{)} \tag{1}\]  
\[H^{(l+1)}=\sigma\Big{(}\widetilde{D}^{-\frac{1}{2}}\widetilde{A}\widetilde{D} ^{-\frac{1}{2}}W^{l}H^{l}+b^{l}\Big{)} \tag{2}\]  
After deriving an adjacency matrix from the road network map and using a GCN, each road segment can have a set of variables that defines it, characterizing them with weather conditions, points of interest, and degree of change from traffic influencers. Furthermore, this will allow the dependency of traffic flow in a road segment with adjacent roads.  
Long-Short-Term Memory Neural Network (LSTM)  
Long-Short Term Memory (LSTM) Neural Networks are a Recurrent Neural Network (RNN) type that avoids the backpropagated error to be blown up or decayed exponentially by inserting an LSTM cell, illustrated in Figure 8, instead of just a Tanh layer.  
The LSTM NN has three gates: (1) the input gate, which controls if the memory cell is updated, and (2) the forget gate, which decides if the memory must be set to 0. And (3) the output gate, which decides if the information on the current state of the cell is made visible. The formulas for each of these gates can be found in Formulas (3), (4), and (5), respectively:  
\[i^{(t)}=\sigma\Big{(}W^{i}\Big{[}h^{(t-1)},\;x^{t}\Big{]}+b^{i}\Big{)} \tag{3}\]  
\[f^{(t)}=\sigma\Big{(}W^{f}\Big{[}h^{(t-1)},\;x^{t}\Big{]}+b^{f}\Big{)} \tag{4}\]  
\[o^{(t)}=\sigma\Big{(}W^{o}\Big{[}h^{(t-1)},\;x^{t}\Big{]}+b^{o}\Big{)} \tag{5}\]  
where \(\sigma\) is the activation function, \(W\) represents the weights, \(h^{(t-1)}\) is the input from the previous computation, \(x\) is the input from the first layer (blue circle in Figure 8), and \(b\) is the bias. This neural network can manage sequence-to-sequence (seq2 seq) problems, using an encoder to translate the input sequence to a vector and a decoder to translate the vector to the output sequence. This scheme is mostly used in text translation, handwriting recognition, speech recognition, and, in this case, traffic prediction.  
The system architecture for this traffic prediction is shown in Figure 9, taking the model from [34] as a base but implementing POIs and traffic influencer analysis.  
Figure 8: LSTM cell in RNN.