# Hybrid Optimization and Explainable Deep Learning for Breast Cancer Detection
## 2 Proposed Methodology
### Data Preprocessing  
In order to guarantee the consistency and quality of the input data used for DL model training and evaluation, the preprocessing stage is essential. In this work, we employed the ImageDataGenerator class from TensorFlow Keras to preprocess and augment the input images before training. This approach enabled us to rescale the pixel values and apply various real-time transformations such as rotation, zooming, and horizontal flipping. These augmentation techniques increased the diversity of the training data and contributed to improving the model's generalization performance by reducing the risk of overfitting. Additionally, the tool facilitated the efficient loading and batching of images directly from organized directories, which streamlined the data pipeline during training. Three datasets were preprocessed for this study: the merged Fusion dataset, the Breast Ultrasound Images dataset, and the MIAS mammography dataset. The photos in the MIAS dataset were initially categorized into test, validation, and training sets before being divided into two classes: benign and malignant. Prior to scaling all photos to a consistent resolution of 224 \(\times\) 224 pixels and converting them to RGB format for convolutional neural network compatibility, the first step in preprocessing was to confirm the image format and content. Normalization (scaling pixel values between 0 and 1) and grayscale conversion were used to provide numerical stability throughout training. The matching class labels were then encoded once the photographs were put into memory as NumPy arrays. After dividing the dataset in an 80/20 ratio into training and test sets, one-hot vectors were used for label encoding. To ensure balanced learning and mitigate bias, class distributions were visualized, and data were shuffled before model input, as illustrated in Figure 6.  
The Breast Ultrasound Images dataset was subject to a unique preprocessing pipeline for ultrasound images. Images were extracted from two named subfolders, namely, benign and malignant, and non-image files were discarded. All the images were rescaled to the size 224 \(\times\) 224, converted into grayscale, and normalized in the range [0, 1]. Grayscale images were converted to RGB by replicating the channel because pretrained CNN models require three-channel input. The dataset was divided by means of stratified sampling into the training and the testing sets, with the preservation of the class proportions, and label encoding was performed (0 benign; 1 malignant). As Figure 7 demonstrates, there is a severe imbalance in the classes in the dataset, as occurring benign cases are more frequent than malignant ones. To overcome this, on the minority (malignant) class, data augmentation was applied using transformations, which included rotation, horizontal flip, and contrast. Not only did this increase class balance in the training data but it also better enabled the model to learn more of the underrepresented patterns.  
Finally, the Fusion dataset, constructed by merging the MIAS and Breast Ultrasound datasets, required unified pre-processing to align differences in imaging modalities and formats. All images were standardized to 224 \(\times\) 224 RGB format and normalized in the same way as the previous datasets. The labels were harmonized into a binary classification scheme. This combined dataset aimed to improve model generalizability by exposing the model to greater variability in breast cancer presentations across imaging types. Following pre-processing, an 80/20 split with label stratification was also employed to separate the fused dataset into training and test sets. The class distribution after fusion, shown in Figure 8, reveals a more balanced and expanded dataset, which serves as a robust foundation for the subsequent training of transfer learning and optimized classification models.  
Figure 6: Class Distribution in the MIAS Dataset.  
Figure 7: Class Distribution in the Breast Ultrasound Images Dataset.