# Unraveling the Impact of Class Imbalance on Deep-Learning Models for Medical Image Classification
## 3 Results and Analysis
### Results and Analysis for One Layer
This stems from its fundamental inability to elaborate on the predictions made by the model for each class, a limitation consistently observed across all implementations with \(R\) packages. Additionally, a discrepancy has been noted in the results presented in Table 1, marked by figures that exceed the actual quantities of predicted labels. This phenomenon suggests the existence of underlying causes presented below:  
* The number of dimensions handled per image. Despite preprocessing that reduces the image set to 900 features, it is high for certain neural networks, limiting their ability to map patterns effectively. However, improved mapping is observed for neural networks developed with the Keras package, especially when working with convolutional layers. In this case, pattern extraction is more efficient because convolutional layers do not specialize in individual pixels but rather in their spatial distribution, as discussed in Section 2.3. * The topology. The experiments in this first part involve only a single layer. This can be addressed by increasing the number of layers, which will be tested in subsequent phases. * The selection of hyperparameters. The neural networks handled by the various packages used in this work allow for the selection of multiple hyperparameters. To keep the experiments less complicated, tests were conducted with the default hyperparameter settings, and adjustments were made only in cases where contrasting results were not achieved or when the tests consumed a significant amount of time (see Section 2.4). * The established epochs for training. The pattern of inefficient predictions observed in all models developed with the R packages may be a result of the limited training, which barely reaches 100 epochs in this initial experiment. During each epoch, the different neural networks need to process and extract information from the images to update their weights; however, 100 epochs may not be sufficient for this task. To address this limitation, subsequent experiments will involve training the best-performing models with more epochs to achieve more robust results. * The number of neurons per layer. Not only the number of layers or topology, as it is often called, can affect the effectiveness of a neural network, but also the number of neurons per layer. However, the optimal models for a single layer have already been presented in Table 1, where the number of neurons can be observed in Column 4. * The dataset used. In the introduction, it has been noted that the dataset can significantly impact the model's performance, including class balance. In this initial experiment, these variables have been controlled. Although the dataset was initially unbalanced, during preprocessing, the quantities of images per class were equalized. The summary in Table 1, particularly in Columns 3, 6, and 7, enables a comparison to understand the data balance's influence. Based on the preliminary discussion and the data from Table 1, a second experiment is conducted using the best models, selected based on the highest values of overall accuracy in both the training and testing sets (see Columns 6 and 7 of Table 1). This entails considering only the models trained with unbalanced datasets (see Column 3 of Table 1). However, not all selected models allowed for the second experiment, so their results are not displayed in Table 2.  
Table 2 summarizes the data obtained after 1000 training epochs and testing for these models. The model selected from Table 1 and the overall accuracy achieved after completing the 1000 training epochs are shown in Columns 1 and 6, respectively. An increase in overall training accuracy is observed in all models. Regarding overall test accuracy, the Keras_30, Keras_150, and Keras_cnn_40 models show improvements, Kera_cnn_450 remains unchanged, and Neuralnet_100 experiences a 2-point decline.