# A Data-Driven Deep Learning Framework for Prediction of Traffic Crashes at Road Intersections
## 4 Model Architecture
### Phase III in RoadInt TCP
\[\omega_{day}=(X_{\Delta t_{q}-\hat{1}\hat{1}},\ldots,X_{\Delta t_{q}-2\hat{1} \hat{1}},X_{\Delta t_{q}-1\hat{1}},X_{\Delta t_{q}}) \tag{12}\]  
Figure 7: An example of input time series to RoadInTCP in Phase III. **(3) Long-term feature time series \(\omega_{week}\)** is a historical time series of the same time period several weeks before the prediction time period, as shown in the bright orange part in Figure 7, which gives the time series for the two weeks before the prediction time period. Similarly, Figure 6a also shows that traffic crash data have obvious cyclical characteristics. For example, the traffic status on Monday is similar to the traffic status on Mondays historically. Thus, a long-term feature time series explores the weekly changing patterns in traffic data. \[\omega_{week}=(X_{\Delta t_{q}-inv},\ldots,X_{\Delta t_{q}-2w},X_{\Delta t_{q} -1w},X_{\Delta t_{q}}) \tag{13}\]  
Because traffic crashes are related to recent-time happenings and historical temporal patterns (such as rush hours or holidays), in Phase III we regard them as time series and propose a temporal aggregation method to capture the latent sequential features in immediate-term, short-term and long-term dependencies. To explore the signals embedded in the sequential features changing over time for TCP, in Phase III of RoadInTCP, a Recurrent Neural Network (RNN) or One-dimensional convolutional neural network (1D-CNN) is used. The input to the model consists of three types of time series \((X_{\Delta t_{q}-inv},\ldots,X_{\Delta t_{q}-2w},X_{\Delta t_{q}-1w},\ldots,X_ {\Delta t_{q}-id},\ldots,X_{\Delta t_{q}-2d},X_{\Delta t_{q}-1d},\ldots,X_{ \Delta t_{q}-ih},\ldots,X_{\Delta t_{q}-2h},\)\(X_{\Delta t_{q}-1h},X_{\Delta t_{q}})\), which contain the time series for the previous \(h\) hours, previous \(d\) days and previous \(w\) weeks of the forecast period, simplified \(s(X_{1},\ldots,X_{h},\ldots,X_{h+d},\ldots,X_{T})\), where \(T=h+d+w\). In Phase II of the RoadInTCP model, the node topological relationship features are extracted through the ST Cell under the corresponding time series and additional thematic information. As shown in Figure 2, in RoadInTCP, the node features of those time series are fed as the input to an RNN model. Specifically, in Phase III of the RoadInTCP model, the LSTM model [31] is used to learn the latent sequential features, specified below. \[h_{t}^{v_{i}}=LSTM(x_{t}^{v_{i}},h_{t-1}^{v_{i}}) \tag{14}\]  
where \(x_{t}^{v_{i}}\) is the output of node \(v_{i}\) at time interval \(t\) and \(h_{t-1}^{v_{i}}\in\mathbb{R}^{D_{h}}\) (\(D_{h}=d_{tr}+d_{ATT}\)) is the dimensionality of the node's latent feature vector related to road network intersections and additional thematic information extracted in Phase I. Let \(H=[h_{t-1}^{v_{1}},h_{t_{a}}^{v_{2}},\ldots,h_{t-1}^{v_{i}}](t_{n}=h+d+w)\), \(h_{t_{n}}\in\mathbb{R}^{V\times D_{h}}\). After obtaining the last hidden state of LSTM \(h_{t_{n}}^{v_{i}}\), we calculate \(\hat{y}_{v_{i}}\) through the \(Sigmoid\) function. \[\hat{y}_{v_{i}}=Sigmoid(FC(h_{t_{n}}^{v_{i}})) \tag{15}\]  
Finally, the same loss function as in Phase II (see Equation (10)) is used to predict traffic crashes.