## 5 Shapley Explanation for the Relationship between Micro-Behavior and Geometric Design
### Methodology  
#### 5.1.1 Random Forest  
There are many methods suitable for the analysis, such as traditional linear regression models, generalized linear regression models, and newer algorithms such as XGBoost, support vector machines, random forests, and so on. The random forest model (RF) is used in this study. RF is a widely implemented machine learning technique capable of addressing both classification and regression problems [25]. RF is a flexible and powerful machine learning algorithm suitable for various types of data, including continuous numerical data, data with classification labels, and mixed-type data. RF involves multiple decision trees that are combined through a majority voting mechanism to generate a final decision [26]. It can be understood as assuming the input features are \(X=(x_{1},x_{2},\ldots,x_{n})\) and \(Y=(y_{1},y_{2},\ldots,y_{n})\) in the RF model, where \(X=(x_{1},x_{2},\ldots,x_{n})\) represents the road geometric design parameters. The meaning of \(Y=(y_{1},y_{2},\ldots,y_{n})\) varies across different combined curves: on downslope curves, it represents both speed variation and lane departure values; on upslope and crest curves, it represents lane departure values; and on sag curves, it represents speed variation. \(n\) is the number of features. The process is (1) select a random sample set \(\{x_{i},y_{i}\}\) from the training dataset \(\{X,Y\}\); (2) generate a decision tree \(f_{i}\) on \(\{x_{i},y_{i}\}\); (3) repeat steps (1) and (2) for n times to obtain decision trees \(\{\,f_{1},f_{2},\ldots,f_{n}\}\); (4) summarize the predictions for each random sample \(\hat{x}\), providing the function \(\hat{f}\) of the RF [27]. RF not only captures complex relationships, but also evaluates the importance of features, allowing interpretation of how features affect the response variable. In addition, RF was able to retain all features, largely due to the use of the bagging learning mechanism, \begin{table}
\begin{tabular}{c c c} \hline \hline
**Road Type** & **Speed Change** & **Lane Departure** \\ \hline Upslope curve & 4.436 & 19.753 \\ Downslope curve & 15.884 & 41.114 \\ Crest curve & 8.435 & 12.482 \\ Sag curve & 5.111 & 2.203 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Coefficient of variation of combined curves with micro-driving behavior. which constructs a large collection of decorrelated trees, thereby reducing overfitting. In addition, each tree in RF is constructed using a randomly selected subset of features from the sample data. In previous studies, RF has been applied to traffic safety research. RF has been established as an effective approach for accident prediction [26; 28; 29], with an increased level of prediction accuracy [30]. [PERSON] [31] developed two models using training and validation datasets to predict traffic accidents using RF. [PERSON] et al. [32] used an RF model to study and evaluate the importance of five continuous variables (average speed, queue length, cumulative number of vehicles in queue, cumulative duration, and cumulative number of vehicles) on traffic flow variables. [PERSON] and [PERSON] [33] used RF as their basic prediction model, and tuned its parameters using Bayesian Optimization (BO), and analyzed the severity of traffic accidents with 15 factors related to traffic, time, and weather. BO-RF provides interpretable results through relative importance and partial dependence plots, allowing the identification of factors with significant impacts on the severity of traffic accidents. The RF model was implemented by calling the RandomForestRegressor from the sklearn library, version 1.0.2, in Python. To ensure the model's generalizability and to prevent overfitting, the code defines the search range for hyperparameters during the construction of the RF model. Each hyperparameter has three possible values, and grid search is employed to automatically find the best combination of hyperparameters.