# Classification of Breast Cancer in Mammograms with Deep Learning Adding a Fifth Class
## 3 Materials and Methods
### Data Augmentation and Transfer Learning
Aiming to feed the neural networks, all regions were changed to the input size of each CNN, being 256 \(\times\) 256 pixels for AlexNet and 224 \(\times\) 224 for GoogLeNet, Resnet50, and Vgg19. According to the number of ROIs obtained after data augmentation, we created two databases of regions of interest, one unbalanced and one balanced. Training employs 70% of ROIs, and the remaining 30% is used for testing. The unbalanced database with the five classes uses 12,582 regions and only 6548 for the training and tests with four categories. In contrast, the balanced database uses 2336 lessons for each type, encompassing 11,680 images when handling the five classes and 9344 areas using four categories. Table 3 summarizes the number of regions used for each database. Initially, we trained the topologies with the unbalanced databases only for four categories, and later the fifth category was added, doing a total of seven classifiers. Afterward, the number of malignant calcifications doubled, and the other classifications equaled this number to balance the database. With this, we trained another six classifiers on the four topologies with 4 and 5 classes. Figure 3 shows the data augmentation for a malignant mass, starting from the original image at the top and the effect after applying the CLAHE method at the bottom; and then increase with its rotations in the clockwise direction of 90\({}^{\circ}\), 180\({}^{\circ}\), and 270\({}^{\circ}\), and later make a turn from left to right and rotate again. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Database** & **Classes** & **ROI per Class** & **Total** & **Training** & **Testing** \\ \hline Unbalanced & 5 & 2517 & 12582 & 8810 & 3772 \\ Balanced & 5 & 2336 & 11680 & 8175 & 3505 \\ Unbalanced & 4 & 1637 & 6548 & 4583 & 1964 \\ Balanced & 4 & 2336 & 9344 & 6540 & 2804 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: ROIs used for balanced and unbalanced databases. Overfitting is an undesirable factor in training; we added a function to avoid it if the neural networks that reached 99.5% accuracy. Under this guideline, AlexNet and GoogLeNet were trained for 20 epochs, while Resnet50 converged much faster, stopped training at the 5 th epoch, and Vgg19 stopped training at the 13 th epoch when using four classes and stopped at the 10 th epoch while training with five classes; all CNNs were trained using the SGDM optimizer with a learning rate \(\alpha=1\times 10^{-4}\) and miniBatch size = 8. Regarding each CNN, we counted the number of true positive cases (TP), which indicate the number of cases correctly identified, followed by obtaining the true negative cases (TN), that is, the number of predictions in which the negative classes are classified correctly. The false positive (FP) cases represent the number of predictions where the classifier interprets a negative class as positive. Finally, the false negative (FN) cases refer to the number of predictions where the classifier predicts the positive class as negative. Regarding the performance metrics, accuracy shows the number of correct predictions made about the different classes. At the same time, the precision indicates the ability of a classification model to identify only the relevant cases and also shows the rate of false positives. Sensitivity or recall indicates the ability of a CNN to detect each case, while specificity indicates the ability to discriminate negative cases between regions without malignancy. From these metrics, while we increase the precision, we decrease the recall and vice versa. Therefore, the F1 Score is added, which is a value that combines recall and precision by using the harmonic mean being more representative than a simple average because it takes into account the false positives and false negatives. An expression for the confusion matrix with multiple classes \((a_{n})\) is shown in (1):  
\[ \begin{array}{ccccc}&a_{11}&\cdots&a_{1n}\\ &\vdots&\ddots&\vdots\\ &a_{n1}&\cdots&a_{nn}\end{array}