# Unraveling the Impact of Class Imbalance on Deep-Learning Models for Medical Image Classification
## 4 Discussion  
The presented research comprehensively addresses the impact of sample imbalance and the configuration of neural network-based models on the reporting capability of metrics used in the classification of pulmonary pathologies. In this regard, experiments were conducted to evaluate classification models under various neuronal configurations and data balance conditions. The central premise was to examine how these variables affect the global accuracy and class-specific performance of the models in detecting pulmonary pathologies from images. In the initial exploration for a single layer, selecting the optimal number of neurons emerged as a critical challenge to achieve high accuracy in training and testing. The findings highlight the complexity of adjusting the network topology to optimize performance, suggesting there is no single rule for neuron configuration that guarantees success. Interestingly, results indicate that models with unbalanced datasets tend to show higher accuracy in training, though this phenomenon does not necessarily translate into improved generalization capability on new data. When analyzing performance on test datasets, it was revealed that global accuracy does not adequately reflect the model's performance with respect to individual classes. Particularly in high-performing models, such as those implemented with the Keras package and its variants with convolutional layers, significant discrepancies were observed in class-specific accuracy. This underscores the importance of looking beyond global metrics to understand the model's behavior in classifying different types of pathologies. The inclusion of additional layers in subsequent experiments provided an opportunity to investigate the influence of more complex topologies on model effectiveness. While marginal improvements in accuracy were observed with the addition of layers, the persistence of data imbalance as a critical factor in evaluating global and class-specific \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{**Table**} & \multirow{2}{*}{**Column**} & \multirow{2}{*}{**Row**} & \multirow{2}{*}{**Accuracy Test**} & \multicolumn{4}{c}{**Accuracy per Class**} \\ \cline{5-6}  & & & & **N** & **V** & **B** \\ \hline Table 3 & 7 & 4 & 0.81 & 0.96 & 0.57 & 0.63 \\ Table 6 & 8 & 4 & 0.79 & 0.96 & 0.52 & 0.58 \\ Table 7 & 10 & 7 & 0.81 & 0.95 & 0.59 & 0.62 \\ Table 8 & 10 & 6 & 0.81 & 0.96 & 0.53 & 0.63 \\ Table 9 & 10 & 5 & 0.82 & 0.98 & 0.51 & 0.69 \\ Table 9 & 10 & 6 & 0.82 & 0.94 & 0.58 & 0.70 \\ \hline \hline \end{tabular}
\end{table} 
Table 10: Contrast of overall and class-specific test accuracies for top-performing keras models with convolutional layers as demonstrated in Tables 3 and 6–9. accuracy remained. Models trained with 1000 or more epochs showed improvements in training accuracy, highlighting the need for a holistic approach to training and evaluating the models' generalization capabilities. The discussion on the informative capacity of global metrics highlights an inherent limitation in capturing the true performance of models in classifying different categories. This aspect is critical, especially in medical applications where accuracy in detecting specific pathologies is paramount. With the proposed data preprocessing techniques, the implemented models are close to the results reported in many previous studies for the same dataset. Assuming the results presented in [26] are associated with test sets, they report an accuracy of 85% with a sensitivity of 84.1%. While these results are very close to this study, they do not address the problems demonstrated in this study. Nor do they detail the effect of classes individually. The work of [26] rather merges the virus and bacteria classes, which can be counterproductive as it may hide potential biases in the final results [51]. It is crucial to prevent the spread of errors among classes. Thus, a class-specific analysis, as conducted in this study, is recommended, demonstrating that individual classes impact model performance.