# Unraveling the Impact of Class Imbalance on Deep-Learning Models for Medical Image Classification
## 3 Results and Analysis
### Results and Analysis for One Layer
However, upon analyzing the record from Columns 8 to 16, an improvement in some classes is reflected, although it is noted that overall accuracy in testing does not truly reflect the model's performance in relation to the individual classes present. This is confirmed in Table 3, where metrics per class obtained from the testing data after completing the 1000 training epochs are presented. These metrics are derived from the confusion matrix introduced in Section 2.5 using the Caret package in R. In Table 3, from Columns 8 to 15, sensitivity, specificity, and precision metrics are shown for each class normal (N), virus (V), and bacteria (B), respectively. \begin{table}
\begin{tabular}{l c c c c c c c c c c c c c c} \hline \hline  & & & & & & & & & & & & & & & \\ \hline keras\_30 & 10-100 & No\_bal & 30 & 1000 & 0.79 & 0.75 & 0.77 & 0.72 & 0.66 & 0.97 & 0.84 & 0.88 & 0.99 & 0.19 & 0.58 \\ keras\_150 & 00-500 & No\_bal & 150 & 1000 & 0.89 & 0.77 & 0.93 & 0.62 & 0.55 & 0.83 & 0.87 & 0.94 & 0.87 & 0.37 & 0.82 \\ keras\_cnn\_40 & 10-100 & No\_bal & 40 & 1000 & 0.95 & 0.81 & 0.89 & 0.63 & 0.72 & 0.94 & 0.90 & 0.89 & 0.96 & 0.57 & 0.63 \\ keras\_cnn\_450 & 100-500 & No\_bal & 450 & 1000 & 0.96 & 0.80 & 0.86 & 0.63 & 0.73 & 0.95 & 0.89 & 0.90 & 0.97 & 0.48 & 0.64 \\ Neuralnet\_100 & 100–500 & No\_bal & 100 & 1000 & 0.77 & 0.58 & 0.83 & 0.27 & 0.64 & 0.63 & 0.87 & 0.83 & 0.65 & 0.56 & 0.29 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Summary of the metrics obtained for 1000 training epochs with one layer and the tests of the different R packages. \begin{table}
\begin{tabular}{l c c c c c c c c c c c c c c} \hline \hline  & & & & & & & & & & & & & & & \\ \hline keras\_30 & 10-100 & No\_bal & 30 & 1000 & 0.79 & 0.75 & 0.77 & 0.72 & 0.66 & 0.97 & 0.84 & 0.88 & 0.99 & 0.19 & 0.58 \\ keras\_150 & 00-500 & No\_bal & 150 & 1000 & 0.89 & 0.77 & 0.93 & 0.62 & 0.55 & 0.83 & 0.87 & 0.94 & 0.87 & 0.37 & 0.82 \\ keras\_cnn\_40 & 10-100 & No\_bal & 40 & 1000 & 0.95 & 0.81 & 0.89 & 0.63 & 0.72 & 0.94 & 0.90 & 0.89 & 0.96 & 0.57 & 0.63 \\ keras\_cnn\_450 & 100-500 & No\_bal & 450 & 1000 & 0.96 & 0.80 & 0.86 & 0.63 & 0.73 & 0.95 & 0.89 & 0.90 & 0.97 & 0.48 & 0.64 \\ Neuralnet\_100 & 100–500 & No\_bal & 100 & 1000 & 0.77 & 0.58 & 0.83 & 0.27 & 0.64 & 0.63 & 0.87 & 0.83 & 0.65 & 0.56 & 0.29 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Summary of the data obtained for 1000 training epochs with one layer and the testing of the different \(R\) packages. The analysis of these metrics reveals a bias in the models' prediction towards the normal class, demonstrated by higher sensitivity and precision for this class, while specificity is more conservative. A deeper analysis of the overall accuracy in tests reveals its limitation in reflecting the performance of class-specific predictions for each model, as demonstrated by cross-referencing data from Tables 1 and 2, which are detailed in Table 4. This table includes, in its first two Columns, the evaluated models and their respective training epochs, while the third column displays the overall accuracy in tests for each model. Columns 4, 7, and 10 detail the actual quantities of labels per class, and Columns 5, 8, and 11 present the class label estimates derived from the overall test accuracy. Considering the keras_30 model (see Row 1 of Table 4), with an overall accuracy of 71%, one would expect approximately 264, 83, and 103 samples for the classes of normal (N), virus (V), and bacteria (B) samples, respectively. However, Columns 6 and 9 reveal that this model predicted 450 and 187 samples for the N and V classes, respectively, and made no predictions for the B class, as shown in Column 12. The percentages contrasting overall test accuracy against class-specific accuracy are examined in Columns 13 to 18, providing a detailed perspective on the observed discrepancies. An additional example highlighting the limited capability of overall test accuracy to reflect class-specific performance is observed in the keras_cnn_40 model (see Row 7 of Table 4).