# A Data-Driven Deep Learning Framework for Prediction of Traffic Crashes at Road Intersections
## 4 Model Architecture
### Phase II in RoadInTCP  
In Phase II, as shown in Figure 5, we develop a Graph Convolution Network (GCN) based module, called ST-Cell by exploiting the road network structure to embed dynamic traffic features and other attributes features to intersections. An ST Cell based on a graph convolutional network (GCN) is designed to aggregate the adjacency characteristics of intersections. During the model training, we also propose a data sampling method for training data preparation to handle the data sparsity problem. In detail, we not only capture the topological-relational features (_tr-features_) of road intersections but the additional thematic information. According to Definition 5, the additional thematic information includes the dynamic features (_dt-features_) and static features (_st-features_). More specifically, the dynamic features contain the average speed of vehicles \(Speed_{v_{l}}(\Delta t)\), estimated traffic flow \(Flow_{v_{l}}(\Delta t)\) and the weather features \(W_{v_{l}}(\Delta t)\), the static features include calendar features \(C_{v_{l}}\), the static speed limitation \(Lim_{v_{l}}\) and environmental features \(E_{v_{l}}\). In our work, we denoted \(X^{\Delta t_{i}}\) as all related intersection features during \(\Delta t\). For these features, we form a feature map by applying an aggregate function (e.g., Hadamard function, Average function or Concat function) to aggregate the topological-relational features and the additional thematic information. In addition, the road network, represented as an adjacent matrix is given as an input to RoadInTCP in Phase II. Directly attempting to predict traffic crashes at every intersection across the entire road network consequently confronts models with the challenge of sparse positive samples, often leading to an overwhelming prevalence of null predictions. In order to handle the data sparsity problem, we propose a data sampling method for training data preparation. In Figure 5, we extract the implicit feature vector of the last layer of each training in the ST Cell. The local optimal is reached by fitting the data samples each day through this data sampling method. In each iteration, an initialization point close to the optimal value can be found after all the data are completed due to the consideration of the sample characteristics of the previous day. Finally, the optimal result is achieved through the model training of the full data. Thus, the latent vector \(Z^{\Delta t_{i}}\) obtained after \(i\) iteration is defined as follows:  
\[Z^{\Delta t_{i}}=ST(X^{\Delta t_{i}}\oplus Z^{\Delta t_{i-1}}) \tag{4}\]  
where \(i\in[1,n]\) is the \(i\) day in \(\Delta t\) interval in the \(n\) day training data. Since there is no hidden layer vector at the beginning, the input of the model includes only the additional thematic information and the features related to intersections extracted from the RoadInTCP model in Phase I, which is denoted as \(X^{\Delta t_{0}}=Emb(tr)\oplus Emb(ATI)\in\Delta t\). The model training data is then fed into the model training data and the model training data is fed into the model training data. Figure 5: The process of RoadInTCP in Phase II. \(\mathbb{R}^{d_{tr}+d_{ATI}}\) where \(d_{tr}\) and \(d_{ATI}\) are the dimensionalities of intersection topological feature embeddings and the additional thematic information, respectively. Thus, the latent vector \(Z^{\Delta t_{0}}\) is defined as follows:  
\[Z^{\Delta t_{0}}=ST(X\Delta t0)=ST(Emb(tr)\oplus Emb(ATI)) \tag{5}\]  
Thus, the number of traffic crashes predicted by the training data of each day after the ST Cell training is defined as follows:  
\[Y^{\Delta t_{i}}=Sigmoid(FC(ST(X^{\Delta t_{i}}\oplus Z^{\Delta t_{i-1}}))) \tag{6}\]  
The ST Cell contains a multi-layer graph convolutional network (GCN) to aggregate the adjacency characteristics of intersections. In this work, we denote \(H^{(0)}_{\Delta t_{1}}\) as the input of the ST Cell, which consists of all feature vectors of road intersections and the embeddings extracted from the hidden layer in the previous layer.