# Investigation of Structural Seismic Vulnerability Using Machine Learning on Rapid Visual Screening
## 2 Materials and Methods
### Explainability and SHAP Values  
SHapley Additive exPlanations (SHAP) is a feature attribution methodology recently introduced by [PERSON] and [PERSON] (2017). They are based on the so-called Shapley values proposed by [PERSON] in the field of cooperative game theory ([PERSON], 1991). They are used to analyze the predictions of a trained Machine Learning model into components pertaining to each individual feature. Specifically, given a trained model \(f\), a local approximation h is constructed as follows ([PERSON] and [PERSON], 2017):  
\[h(\mathbf{z})=\phi_{0}+\sum_{i=1}^{m}\phi_{i}z_{i}, \tag{3}\]  
where \(m\) is the number of features employed by the machine learning model, \(\mathbf{z}\in\{0,1\}^{m}\) is a binary vector indicating whether the \(i^{\text{th}}\) feature was used in the prediction, and \(\phi_{i}\) is the SHAP values corresponding to that feature. The values of \(\phi_{i}\) are computed in such a way that the so-called \"local accuracy\" property holds ([PERSON] and [PERSON], 2017), i.e., that they approximate the behavior of the underlying model \(f\). To this end, they are given by the formula ([PERSON] and [PERSON], 2017; [PERSON] and [PERSON], 2017)  
\[\phi_{i}=\sum_{S\subseteq N\setminus\{i\}}\frac{|S|!(n-|S|-1)!}{n!}[f(S \cup\{i\})-f(S)]. \tag{4}\]  
Following the notation of [PERSON] et al., in the above Equation (4) \(M=1,2,...,m\) is the set of features employed by \(f\) and \(S\subset M\) is a subset of M called \"coalition\", using the term from cooperative game theory. Intuitively, the contribution of each feature is measured as a weighted average of the model's predictions with and without the inclusion of the particular feature.  
The above provides a motivation to employ these SHAP values as the weights \(\mathbf{w}\) in our proposed formulation for the recalibration of RVS, which was presented in Section 2.5. However, these SHAP values are computed for each individual data point in the dataset, i.e., for each individual pair of structures. Thus, they are given in the form of a matrix \(\mathbf{\Phi}^{k\times m}\), where \(k\) is the number of pairs of structures in the transformed dataset and \(m\) is the number of features each Seismic Code employs. In order to provide a single weight for the whole dataset, the computed values must be aggregated. To this end, we employed a normalized (dividing by the dimension of the vector) norm of each column in the matrix. The \(\mathcal{L}_{1}\) norm, i.e., the sum of absolute squares, is one of the most commonly employed ones in the literature. As an alternative, we employed the \(\mathcal{L}_{2}\) norm, i.e., the well-known Euclidean norm. Specifically, we computed [18]  
\[\overline{\phi}_{j}=\left\{\begin{array}{ll}\frac{1}{m}\sum_{i=1}^{m}|\phi_{ ij}|,&\text{using }\mathcal{L}_{1}\\ \frac{1}{m}\sqrt{\sum_{i=1}^{m}\phi_{ij}^{2}},&\text{using }\mathcal{L}_{2} \end{array}\right.. \tag{5}\]  
A fundamental difference between the two is that the \(\mathcal{L}_{2}\) norm tends to reduce the contribution of small, noisy components, while simultaneously highlighting the effect of the most prominent features [18]. This is due to the fact that it is based on squaring the terms before summation. Thus, using the \(\overline{\phi}_{j}\) as defined in (5), we can define the weights \(\mathbf{w}\) of our proposed recalibration procedure for RVS. In the present study, the formulations using \(\mathcal{L}_{2}\) outperformed the formulation using \(\mathcal{L}_{1}\). Thus, the results we will present are based on this approach. The computation of the SHAP values was carried out using the dedicated Python library by [PERSON] et al. [35].