# Severity Prediction of Highway Crashes in Saudi Arabia Using Machine Learning Techniques
## 3 Materials and Methods
### Methods
#### 3.3.7 Model Interpretation  
SHapley Additive exPlanations (SHAP) is a method to explain the individual predictions of any machine learning model. SHAP is based on the game theoretically optimal Shapley values [66]. SHAP aims to explain the prediction of instance x by computing the contribution of each feature [67]. It is frequently adopted due to its durability, solid theoretical foundation, fair distribution of prediction among features, fast implementation for tree-based models, and global model interpretations. It includes feature importance, feature dependence, interactions, clustering, and summary plots.  
Equation (14) generates the Shapley value for a feature i. For a specific feature value (float number), the inputs for the blackbox model \(f\), and the input datapoint \(x\), this datapoint will be a singular row in the dataset. Iterate the overall possible subset prime combination of features to ensure that the interaction between individual feature values is  
\begin{table}
\begin{tabular}{c c c} \hline \hline \multicolumn{3}{c}{**XGBoost Hyperparameter Optimization**} \\ \hline Parameter & Typical Value & Values \\ \hline learning\_rate & 0.01 to 0.2 & 0.05, 0.10, 0.15, 0.20, 0.25, 0.30 \\ \hline max\_depth & 3 to 10 & 3, 4, 5, 6, 8, 10, 12, 15 \\ \hline min\_child\_weight & N/A & 1, 3, 5, 7 \\ \hline gamma & N/A & 0.0, 0.1, 0.2, 0.3, 0.4 \\ \hline n\_estimators & N/A & 10, 50, 100, 150, 200, 250, 300 \\ \hline colsample\_bytes & 0.5–0.9 & 0.3, 0.4, 0.5, 0.7 \\ \hline \hline \multicolumn{3}{c}{Random Forest Hyperparameter Optimization} \\ \hline max\_depth & 3 to 10 & 3, 4, 5, 6, 8, 10, 12, 15 \\ \hline min\_samples\_leaf & & 1, 5, 10 \\ \hline min\_samples\_split & N/A & 2, 4, 10, 12, 16 \\ \hline n\_estimators & & 10, 50, 100, 150, 200, 250, 300 \\ \hline criterion & Gini or Entropy & Gini or Entropy \\ \hline \multicolumn{3}{c}{Logistic Regression Hyperparameter Optimization} \\ \hline c\_values & 100, 10, 1.0, 0.1, 0.01 \\ \hline penalty & N/A & 11 and l2 \\ \hline solvers & & Newton-cg, lbfgs, or liblinear \\ \hline \hline \end{tabular}
\end{table}
Table 2: Hyperparameter optimization off ML models.  
accounted for. One of the subsets could be any other feature, and the remaining are treated as unknown values. By this, consideration is left only to the selected feature:  
\[\phi_{i}(f,x)=\sum_{z^{\prime}\subseteq x^{\prime}}\frac{|z^{\prime}|!(M-|z^{ \prime}|-1)!}{M!}[f_{x}\big{(}z^{\prime}\big{)}-f_{x}\big{(}z^{\prime}/i\big{)}] \tag{14}\]  
where \(\phi_{i}\) (\(f,x\)) is the Shapley value for a feature \(i\), \(f\) corresponds to the blackbox model, \(x\) refers to the input data point, \(z^{\prime}\) represents the subset feature, \(x^{\prime}\) stands for the simplified data input, and \(M\) denotes the total number of features.  
The core step is to get the blackbox model \(f\) output for the subset with \(f_{x}(z^{\prime})\) and without \(f_{x}(z^{\prime}/i)\) for the feature desired (i.e., interested in \(i\)). The difference in these two terms reveals how much \(i\) contributes to the prediction in the subset known as the marginal value. Repeating these for all the possible combinations, each permutation of subsets for each of those is additionally weighted according to how many players in that collation.