The subsections that follow describe the target variable, feature selection, and ML models evaluated.
3.4.1. Feature Selection
This study sought to identify incident-level characteristics associated with counties exhibiting elevated PI values during Epoch 1. The objective was not to estimate causal effects, but rather to identify variables that most effectively distinguish incidents occurring within counties belonging to high-persistence spatial clusters from incidents occurring elsewhere. Epoch 1 incident records were linked to county-level local Moran’s I results. Counties classified as HH or HL clusters were considered members of the high-persistence group because both categories represent elevated PI values. A binary target variable was assigned to each incident record:
This formulation converts the problem into a binary classification task in which the model identifies incident attributes associated with counties exhibiting elevated persistence characteristics. Since the same county-level label is applied to every incident regardless of its individual timing or circumstances, results should be interpreted as describing aggregate incident-environment differences between high- and low-persistence counties rather than incident-level causal or county-formation mechanisms. Categorical variables were transformed through one-hot encoding (OHE), while numeric variables were retained as continuous measures. This approach preserves category-specific information while avoiding artificial ordinal relationships among categorical levels.
Preliminary evaluation of multiple candidate classifiers within the ML pipeline indicated that RF provided the highest predictive performance and was therefore selected to identify the set of features that contribute most to class discrimination. The RF classifier is an ensemble-learning algorithm that constructs a large collection of decision trees using bootstrap samples (random subset with replacement) of the training data and random subsets of predictors. The final prediction is obtained by averaging predictions across all trees:
where:
∙ = final predicted probability of membership in the positive class
∙ T = total number of trees in the forest
∙ = predicted probability from tree t
This bootstrap aggregation (bagging) reduces prediction variance, while random predictor selection at each split decreases correlation among trees and improves generalization performance. These properties make RF particularly suitable for applications involving nonlinear relationships, interactions, and mixed predictor types.
To reduce potential bias toward the majority class, the RF model incorporated balanced class weighting. Class weights were assigned inversely proportional to class frequencies:
where:
∙ wc = weight assigned to class c
∙ N = total number of observations
∙ K = number of classes
∙ Nc = number of observations belonging to class c
This weighting increases the influence of minority-class observations during model construction and improves discrimination when class frequencies are unequal.
Model performance was evaluated using repeated stratified cross-validation. Stratification preserves class proportions within each fold, while repeated sampling reduces sensitivity to any single train–test partition. Predictive performance was quantified using the area under the receiver operating characteristic curve (ROC–AUC):
where:
∙ = predicted score for a randomly selected positive observation
∙ = predicted score for a randomly selected negative observation
The ROC–AUC represents the probability that the classifier assigns a higher score to a randomly selected positive observation than to a randomly selected negative observation. Values near 0.5 indicate random discrimination, whereas values approaching 1.0 indicate strong separation. Precision–recall area under the curve (PR–AUC) was also computed because it provides a more informative assessment when positive observations constitute a minority of the dataset. Mean and standard deviation values for both metrics were calculated across all validation folds to evaluate predictive stability.
Feature importance was evaluated using two complementary approaches. The first approach used RF impurity-based importance, which quantifies the cumulative reduction in node impurity attributable to a feature across all tree splits:
where:
∙ If = cumulative RF importance for feature f
∙ Sf = number of tree splits involving feature f
∙ = reduction in Gini impurity produced by split s
Categorical variables represented by multiple one-hot encoded columns were grouped to obtain a single importance value for each original predictor. This grouped importance was calculated by summing the impurity reductions associated with all one-hot encoded levels belonging to the same original variable.
The second approach used permutation importance, which measures the decline in predictive performance after randomly shuffling a feature while holding all other variables unchanged:
where:
∙ PIf = permutation importance for feature f
∙ Moriginal = baseline model performance
∙ Mpermuted,f = model performance after random permutation of feature f
A larger decrease indicates that the feature contributes more substantially to predictive performance.
A feature was retained when the overall model demonstrated predictive discrimination exceeding random performance and at least one importance metric indicated a positive contribution. Specifically, variables were retained when the mean cross-validated ROC–AUC exceeded 0.50 and either the grouped RF importance or permutation importance was greater than zero. The dual-importance framework was adopted because impurity-based importance reflects how strongly a feature contributes to tree construction; whereas permutation importance directly measures the reduction in predictive performance attributable to that feature. Agreement between these metrics provides stronger evidence of predictive relevance than reliance on a single importance measure alone. Overall, this multivariate feature-selection framework identified variables associated with incidents occurring within high-persistence counties while accounting for nonlinear relationships, higher-order interactions, mixed predictor types, and class imbalance. The resulting feature subset was subsequently used for explainable ML analysis and interpretation.
3.4.2. Model Selection
The objective of the ML stage was to identify characteristics associated with incidents occurring in counties exhibiting elevated PI patterns (HH or HL) during Epoch 1. The modeling objective was therefore a supervised binary classification problem that distinguished incidents occurring within high-PI county environments from incidents occurring elsewhere. The resulting models were interpreted as predictive association models rather than causal models.
Predictor variables included both numeric and categorical incident characteristics. Numeric variables were standardized to improve numerical stability and comparability among predictors. Categorical variables were transformed using OHE. For a categorical variable containing
K unique categories, the OHE procedure generated
K binary indicator variables:
where:
∙ = encoded binary feature for observation i and category k
∙ i = incident record
∙ k = category level of the original categorical variable
OHE preserves the nominal nature of categorical variables while allowing nonlinear ML algorithms to utilize category-specific information without imposing artificial ordinal relationships.
Model performance was evaluated using repeated stratified cross-validation to ensure robust estimation of predictive capability while preserving class proportions within each fold. The mean performance metric across all folds was computed as:
where:
∙ = mean performance metric
∙ Mr = metric value from repetition r
∙ R = total number of cross-validation repetitions
Based on recommended standard practice, the cross validation used five stratified folds repeated three times, resulting in 15 independent train–test evaluations for each candidate model. Performance was assessed using ROC-AUC because, unlike other methods, it evaluates ranking performance independently of classification thresholds and is less sensitive to class imbalance than overall accuracy.
In addition to RF, a diverse set of additional ML algorithms was evaluated to capture different forms of predictor–response relationships. The candidate models were intentionally selected to span interpretable linear methods, ensemble bagging approaches, and gradient-boosting methods.
Logistic regression (LR) served as the baseline statistical model due to its interpretability and well-established use in transportation safety analysis. The logistic model estimates the probability that an incident belongs to a high-PI county as:
where:
∙ = probability of membership in the high-PI class
∙ = intercept term
∙ = coefficient for predictor j
∙ = value of predictor j
∙ p = number of predictors
Logistic regression provides a transparent benchmark against which more complex nonlinear models can be compared. Its coefficients can be directly converted to odds ratios, facilitating interpretation of feature directionality.
Gradient boosting (GB) was included because it sequentially improves model performance by concentrating on observations that are difficult to classify. The additive boosting model can be expressed as:
where:
∙ = boosted model after iteration m
∙ = model from the previous iteration
∙ = newly fitted weak learner
∙ = learning rate coefficient
∙ m = boosting iteration
GB complements RF by reducing bias rather than variance, thereby improving representation of subtle nonlinear relationships.
XGBoost (XGB) extends traditional gradient boosting through regularization, efficient tree construction, and optimized handling of class imbalance. XGB is an ensemble-learning algorithm that sequentially constructs decision trees to minimize a regularized objective function. The objective function is:
where:
∙ = objective function at boosting iteration t
∙ n = number of observations
∙ = differentiable loss function
∙ = observed class label for observation i
∙ = predicted probability at iteration t
∙ = decision tree added during boosting iteration k
∙ = regularization penalty applied to tree k
The regularization term controls model complexity and reduces overfitting:
where:
∙ T = number of terminal nodes within the tree
∙ = prediction weight associated with terminal node j
∙ = penalty controlling tree growth
∙ = L2 regularization coefficient
XGB was included because it frequently achieves superior predictive performance on structured transportation datasets containing heterogeneous predictor types [
45].
Light gradient boosting machine (LGBM) was selected as a complementary boosting approach that uses histogram-based splitting and leaf-wise tree growth. The optimization objective can be represented as:
where:
∙ Obj = optimization objective
∙ Loss = classification loss function
∙ Complexity = tree-complexity penalty
∙ = regularization parameter
Compared with XGB, LGBM often produces deeper local partitions and may reveal alternative predictor structures. Evaluating both methods reduces dependence on the assumptions of any single boosting implementation.