# An Efficient Explainability of Deep Models on Medical Images
## 3 Materials and Methods
### Visual Explainability  
In order to achieve the main objective, which is the explainability of the results, the best model for each dataset is selected, as illustrated in Figure 6. Then the advanced explanability methods \"Grad-CAM, Vanilla Gradient, LIME, SmoothGrad and integrated gradient\" are performed to the results of these selected models. This approach enables to obtain precise and intuitive explanations of the decisions made by the proposed models. Figure 5: Architecture based on pre-trained CNN models. Figure 6: Contribution of visual explainability. The need to explain deep learning-based methods is increasing as the number of such approaches grows, especially in the high-stakes decision-making field of medical image analysis [7]. The findings of the DL system are explained and interpreted for easy comprehension by medical professionals, which can help them to diagnose COVID-19, tuberculosis and pneumopathy quickly and accurately [8]. For this reason, the XAI algorithms currently in widespread use: Vanilla Gradient, Integrated Gradient, LIME and GradCAM are used in this work. The basic principle of GradCAM is to calculate the gradient of a given output of interest from the neural network (usually the class whose classification we want to explain) and to calculate the gradient of this specific output neuron down to the last convolution layer, as this is considered to be the layer that contains the most detailed abstraction of the patterns that form the image and would therefore have the greatest potential to generate the most explanatory visualization [9]. Thus, for a given class c, we have in Equation (1):  
\[a_{c}^{k}=\frac{1}{Z}\sum V_{k}y^{c} \tag{1}\]  
where \(y^{c}\) represents the specific output of a class c of the network, k represents an attribute map of the last convolution layer of the CNN, \(Z\) is the total number of pixels of this attribute map and the sum is defined on the dimensions of this map. On the other hand, \(a_{c}^{k}\) is a number that represents the influence or weight of one of the attribute maps k on the output neuron c. The sum of all the pixels in the attribute map divided by the total number of pixels is also known as the global average. According to [PERSON] et al. [10], the choice of global averaging over other forms of averaging or data grouping was made empirically to produce the best results. The heatmap is then given by the linear combination of attribute maps, whose weights are the _ak_ values calculated in Equation (2). \[H_{GradCAM}=Relu(\sum_{k}a_{c}^{k}A^{k}) \tag{2}\]  
where LIME [11], also known as Local Interpretable Model-agnostic Explanations, is based on a surrogate model. The surrogate model is usually a linear model built from different samples of the main model. To do this, LIME samples points around an example and evaluates the models at these points. LIME generally calculates the allocation on a sample basis. It takes a sample, perturbs it several times according to random binary vectors and calculates the output scores in the original model. It then uses the binary features (binary vectors) to train an interpretable surrogate model to produce the same outputs. Each of the coefficients in the trained linear substitution model serves as an allocation of the input characteristic in the input sample [12]. Let \(x=h(x^{\prime})\) be a mapping function between \"interpretable inputs\" \((x^{\prime})\) and \"original inputs\" \((x)\) Furthermore, let \(x^{\prime}\in\{0,1\}\), M be the number of simplified features, and \(\phi i\in\mathbb{R}\). The local interpretable explanation model is defined as follows in Equation (3):  
\[x^{\prime}=\varnothing_{0}+\sum_{1}^{M}\varnothing x_{i}^{\prime} \tag{3}\]  
The explanation model g can be obtained by solving the following optimization problem in Equation (4):  
\[\xi=argmin_{g\in G}\left(f,g,\pi_{x}^{\prime}\right)+\Omega(g) \tag{4}\]  
where \((x^{\prime})\) and \(h(x^{\prime})\) are constrained to be equal.