# Helping CNAs Generate CVSS Scores Faster and More Confidently Using XAI
## 4 Methodology
### XAI Algorithm Selection  
Choosing the right algorithm among the hundreds of explainers that exist is not an easy task. However, just like we did to choose the right model, we can make informed decisions based on the following:  
* Both local and global explanations: Since analysts will need help understanding the global changes of patterns after each update of the model as well as the local factors that helped the model make the decision, we preferably need an explainer that can generate both local and global explanations. * Multi-class attribution: Since some metrics have more than 2 classes, we need explainers that can generate multi-class explanations rather than binary coloration. Some binary explainers can be tinkered with to perform multi-class explainability by generating multiple \"one class versus all\", one for each class, and manually interpreting the results. However, explainers that can perform that naturally are preferred. * Relatively fast explanation generation: Since analysts need to deal with multiple vulnerabilities at once, algorithms that take relatively little time to generate explanations are preferred. * Scalability and versatility: As analysts start using explainable ML solutions, they might come up with ideas of their own to improve the solution. Therefore, explainers that can be expanded, upgraded, and personalized are preferred. Considering the previous points, we decided to adopt Shapley Additive exPlanations, commonly known as SHAP [32], as our explainer. Introduced in 2017, SHAP provides a unified approach to explain the contribution of each input feature to the final prediction of a  
Figure 11: Visual representation of the XGBoost algorithm, taken from the official website. model by using calculated values known as Shapley values. A Shapley value represents the marginal contribution of a feature to the prediction, averaged over all possible combinations of features in the dataset. To compute the Shapley values for a specific prediction, SHAP applies a game-theoretic approach based on cooperative games. It treats each feature value as a \"player\" in the game and calculates the contribution of each player to the final prediction. The average contribution of each player is then determined across all possible coalitions of players, with each coalition weighted by its probability of occurrence. This methodology generates a set of Shapley values, which indicate the relative importance of each feature for predicting a specific instance. These Shapley values can be utilized to generate an explanation, highlighting the features that had the most significant impact and how they influenced the outcome. The mathematical formula used by SHAP to generate the Shapley values is presented in the greenfollowing equation:  
\[\phi_{i}(x)=\sum_{S\subseteq N\setminus\{i\}}\frac{|S|!(|N|-|S|-1)!}{|N|!}[f(x _{S}\cup\{x_{i}\})-f(x_{S})] \tag{1}\]  
where \(\phi_{i}(x)\) represents the Shapley value for feature \(i\) in input \(x\) and \(S\) is a subset of the set of all features \(N\) (excluding feature \(i\)). The summation symbol \(\sum\) iterates over all possible subsets \(S\) of \(N\) without including feature \(i\), \(|S|\) is the number of features in subset \(S\), and \((|N|-|S|-1)!\) represents the number of ways to arrange the remaining features in \(N\) after removing those in subset \(S\). \(|N|!\) is the factorial of the total number of features in \(N\), \(x_{S}\) represents the input with only the features in subset \(S\) active, \(x_{i}\) represents the feature \(i\) being considered for its Shapley value, \(f(x_{S}\cup\{x_{i}\})\) is the model's prediction when both feature \(i\) and the features in subset \(S\) are active, and finally, \(f(x_{S})\) is the model's prediction when only the features in subset \(S\) are active. The formula calculates the difference between the model's predictions when feature \(i\) is added to the set of active features and when it is not for all possible combinations of subsets.