# Analyzing Important Elements for Improving the Safety of Motorways
## 4 Modeling: Negative Binomial Regression Model and DNN Model with SHAP
### Model Development and SHAP-Based Feature Importance Derivation  
The evaluation results of the DNN model are presented in Table 7. These metrics show that the MAE was 1.27, the MSE was 3.21, and the RMSE was 1.79. In comparison to the negative binomial regression model, the DNN model exhibited improvements across all evaluation metrics: MAE improved by 3.33%, MSE by 2.72%, and RMSE by 1.37%. These findings indicate that the DNN model surpassed the negative binomial regression model across all performance metrics. The identification of significant variables with high importance in the DNN model involved the application of SHAP, a form of XAI. SHAP values serve as quantitative metrics that evaluate the contribution of each feature (i.e., variable) to the model's specific predictions [32]. For the SHAP analysis, the Kernel explainer was employed, which is model-agnostic and can be utilized regardless of the model's internal structure. It assesses the influence of each feature on the predictions through feature sampling [25]. A bar plot illustrating the global explanation derived from SHAP values is depicted in Figure 2. This bar plot showcases the mean absolute SHAP values for each feature, highlighting the overall contribution of each feature to the model's predictions across the entire dataset. Features ranked higher in the bar plot have a stronger influence on the model's predictions [33]. The analysis of the bar plot reveals that Conzone Length (ConzLength) has the most significant impact on accident frequency, followed by Total Traffic Volume (TotalVolume), Truck Traffic Ratio (TruckRatio), Number of Hazardous Driving Behaviors (HazardousBehavior), and Congestion Duration (CongTime). \begin{table}
\begin{tabular}{c c} \hline \hline
**Category** & **Optimized Value** \\ \hline Dense layer & 3 \\ \hline Batch size & 32 \\ \hline epochs & 300 \\ \hline optimizer & Adam \\ \hline init & glorot\_uniform \\ \hline activation & relu \\ \hline dropout rate & 0.2 \\ \hline neurons & 32 \\ \hline \hline \end{tabular}
\end{table} 
Table 6: Hyperparameter optimization results of the DNN model. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Category** & **MAE** & **MSE** & **RMSE** \\ \hline Negative Binomial regression model & 1.3170 & 3.3001 & 1.8166 \\ \hline DNN model & 1.2732 & 3.2103 & 1.7917 \\ \hline Performance Improvement Rate (\%) & 3.33 & 2.72 & 1.37 \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Evaluation of the DNN model. A beeswarm plot was created in addition to the bar plot to delve deeper into the model's estimation algorithm and gain a more comprehensive understanding [34]. This beeswarm plot, providing both global explanations and local data point information, is depicted in Figure 3. It visualizes the distribution of SHAP values for each feature, with each data point representing the SHAP value for an individual data point. The positioning of points along the x-axis is based on the magnitude of their SHAP value, where positive SHAP values contribute to an increase in the estimate and negative SHAP values contribute to a decrease. A wider distribution indicates a greater variance in the feature's influence across different data points. Furthermore, the color of each point corresponds to the value of the feature, with red denoting higher values and blue denoting lower values. Therefore, a preponderance of red points at positive SHAP values suggests that higher feature values increase the estimate, while blue points at positive SHAP values indicate that lower feature values lead to an increase in the estimate. This plot provides a granular view of how each feature impacts the model's predictions on both a global and local scale. Consistent with the bar plot findings, Conzone Length (ConzLength) and Total Traffic Volume (TotalVolume) exhibited the most substantial influence on traffic accident frequency, followed by Truck Traffic Ratio (TruckRatio), Number of Hazardous Driving Behaviors (HazardousBehavior), and Congestion Duration (CongTime), which demonstrated similar levels of influence.