## 4 Prediction Model and Numerical Testing
### National Highway Crash Prediction and Warning Model  
Developing prediction and accident warning models for shock wave propagation is a challenging task. In this study, the data analysis results discussed in Section 3 were used to confirm the causal relationship between shock wave propagation and traffic accident occurrence. The associations between traffic flow, shock wave propagation, mean speed difference, space headway, time headway, and gantry location were examined, and the dataset of traffic accidents related to speed differences was used as the training dataset. After the problem of imbalanced data was addressed, a DNN model was trained to detect the occurrence of shock waves, send early warnings to road users, and thereby prevent traffic accidents. The model development process focused on two stages: (1) the processing of imbalanced data and (2) the prediction of traffic accidents and announcement of early warnings. Figure 5 depicts the model framework. In Figure 5, the balanced dataset in the second stage includes traffic flow information for the upstream gantry area, the current gantry area, and the downstream gantry area. Traffic flow information includes vehicle number, lane occupancy, and average speed. The above information is used as input to the deep learning model to train the model. Table 2 describes the content and parameter summary of the deep learning model. The examined data were imbalanced because the numbers of data labeled with traffic accidents and no-accident instances differed substantially. For instance, at gantry 01F1960S and its neighboring upstream and downstream gantries (01F1906S and 01F2011S, respectively), of the 105,119 data entries obtained in this study, only 703 were labeled with traffic accidents. To address the problem of imbalanced data, three methods, namely class weight, oversampling, and focal loss methods, were evaluated. The class weight and oversampling methods assigned large weights to specific categories of data, thereby allowing these data  
Figure 5: Framework of the crash prediction and warning model for national highways. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Layer (Type)** & **Output Shape** & **Param** \\ \hline dense (Dense) & (None, 11) & 110 \\ \hline dense\_1 (Dense) & (None, 11) & 132 \\ \hline dense\_2 (Dense) & (None, 1) & 12 \\ \hline Total params: 254 & & \\ \hline Trainable params: 254 & & \\ \hline Non-trainable params: 0 & & \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Deep learning model summary description. to have a greater effect on model training and fitting compared with other categories of data. By contrast, the focal loss method adjusted the loss function of a prediction model to address imbalanced data. Comparison of the three methods indicated that the class weight method was the most appropriate for training and validating the proposed model. A DNN was used to develop the prediction model. Nine types of traffic characteristic data in the accident labeling dataset were used for model construction. Specifically, the data were randomly divided into a model training dataset (80%) and a validation dataset (20%). The developed DNN had a multilayer perceptron structure, and its configuration is described as follows:  
1. Due to the different units of traffic flow volume, density, and speed data, min-max normalization was used to standardize the input eigenvalues. 2. DNN parameters were initialized. The DNN model consisted of four fully connected layers (i.e., one input layer, two hidden layers, and one output layer) and included parameters such as connection weights and bias. 3. The input layer had 10 eigenvalues, and each of the two hidden layers had 11 neurons. Since the accident prediction results were binary solutions (indicating whether an accident occurred), the model had only one output layer. 4. DNN forward propagation 1. The input layer receives normalized data and transmits them to the hidden layers.