## 4 Empirical Assessment Using Real-World Data
### Experimental Design
#### 4.2.1 Classification Stage
RF operates on the principles of Classification and Regression Trees (CART), amalgamating a multitude of decision trees to increase prediction accuracy and mitigate overfitting--a common drawback of single-decision-tree models. The RF algorithm enhances generalization by constructing a \"forest\" of trees, each predicated on a random subset of the data, and making decisions based on a diverse array of predictor variables. Each tree in the forest votes for a class label, and the class receiving the most votes becomes the model's prediction. The individual trees within an RF model are grown using the following steps:  
* **Bootstrap Sampling:** A bootstrap sample from the overall data is used to grow each tree, promoting variability amongst the trees. * **Random Predictor Selection:** At each split within a tree, a random subset of predictors is considered, which ensures that the trees in the forest are uncorrelated and strengthens the ensemble's predictive power. * **Out-Of-Bag Error Estimation:** For each tree, the out-of-bag (OOB) data not included in the bootstrap sample serve as a validation set to estimate prediction error, offering an unbiased evaluation of model performance without the need for a separate test set. The final decision in an RF model is typically made by averaging the predictions (regression) or taking a majority vote (classification) from all of the trees. The model's efficacy is further optimized through parameters such as the number of trees, the maximum depth of each tree, and the minimum samples required at each leaf node. The Information Gain Ratio (IGR), a modification of the traditional Information Gain, is utilized as a splitting criterion in the RF algorithm, calculated as follows:  
\[\text{Information Gain Ratio}(\text{IGR})=\frac{\text{Information Gain (X)}}{\text{Split Info (X)}} \tag{17}\]  
where \(X\) is a randomly chosen example from the training set, Information Gain measures the reduction in entropy or impurity before and after the split, and Split Info measures the potential information generated by the split, accounting for the number and size of branches. XGBoost is a sophisticated ensemble technique that builds upon the principles of gradient boosting and extends it through advanced regularization techniques and system optimization. The XGBoost algorithm combines the predictions from a series of decision trees, summing the contribution of each to forecast crash occurrences:  
\[\hat{y}_{i}(x)=\sum_{T=1}^{T}f_{T}(x),\ \ \ (f_{T}\in F) \tag{18}\]  
where \(\hat{y}_{i}(x)\) is the prediction for instance \(i\), \(T\) represents the number of trees, \(f_{T}\) is an individual tree, and \(F\) signifies the function space of all possible trees. The objective function of XGBoost, which it seeks to minimize, encompasses a loss function that gauges the accuracy of predictions and a regularization term to mitigate overfitting:  
\[Obj(\theta)=\sum_{i=1}^{n}l(y_{i},\hat{y}_{i})+\sum_{T=1}^{T}\Omega(f_{T}) \tag{19}\]  
The loss function is denoted by \((y_{i},\hat{y}_{i})\), measuring the divergence between the predicted value \(\hat{y}_{i}\) and the actual value \(y_{i}\). The regularization term, \(\Omega(f_{T})\), penalizes complexity, reducing the risk of overfitting. In our analysis, the evaluation of the predictive performance of the models applied to Korean road crash frequency data relied on the foundational tool of the confusion matrix, along with key performance metrics such as accuracy, precision, and recall. This approach is commonly used to evaluate the performance of classification models. A confusion matrix is a tabular representation of actual versus predicted conditions, providing a clear visualization of the performance of a classification model. For a binary classifier, the confusion matrix, as shown in Table 3, consists of two rows and two columns that report the numbers of the following:* True positives (TP): Correctly predicted positive observations. * False positives (FP): Incorrectly predicted positive observations (type I error).