## 3 Materials and Methods
### Model Architecture and Training
#### 3.2.1 Data Pre-Processing  
Due to data noise, the final prediction may not be as accurate as the raw data. Pre-processing, which includes under-sampling, data augmentation (over-sampling), scaling, and normalization, is necessary to make the images more suitable for training the proposed models.  
Under-Sampling refers to a set of methods that aim to even out a classification dataset's class distribution when it is skewed. By keeping all of the data in the minority class and reducing the size of the majority class, under-sampling attempts to balance uneven datasets. It is one of the methods used to obtain more accurate information from datasets that were initially imbalanced. The simplest method for under-sampling is random under-sampling, which removes examples from the training dataset at random from the majority class. This procedure can be repeated until each class has the same number of examples.  
Since the images of various diseases in the Kvasir-Capsule dataset were not evenly distributed, and although there were numerous images of common diseases, only a small number of images of rare diseases were utilized for training; we applied the under-sampling technique to solve this issue by decreasing the size of all training, test, and validation sets' classes that had more than 200 images to 200 images.  
Data augmentation refers to a set of methods for artificially increasing the number of data by creating new data points from existing data or creating new synthetic data from existing data. By creating new and distinct examples to train small datasets, data augmentation can help DL models perform better and produce better results. A DL model performs better and is more accurate when the dataset it uses is extensive and sufficient. Data collection and labeling can be time-consuming and expensive processes for DL models, but the use of data augmentation techniques can reduce these operational costs by transforming datasets.  
Simple alterations to visual data are popular for data augmentation. For data augmentation, typical image processing tasks include padding, re-scaling, vertical and horizontal flipping, zooming, random erasing, random rotating, translation (where the image is moved in the X and Y directions), color modification, cropping, gray scaling, changing contrast, and adding noise. Data augmentation improves the model's accuracy, lowering the costs of data collection and labeling, enabling the prediction of rare events, and preventing issues with data privacy.  
Since the size of the Kvasir-Capsule and Kvasir v2 datasets was small, we generated WCE images from existing WCE images to increase the dataset's size. We altered the values of five attributes of the existing WCE images using the augmentation method. Table 4 shows the used attributes and their values.  
By using the data augmentation technique, we increased the number of images in all training set classes of the Kvasir-Capsule dataset that had fewer than 200 images to a total of 200 images each. Specifically, the class \"erythema\" gained 111 images; the class \"blood hematin\" increased by 193 images; the class \"ampulla of Water\" grew by 194 images; and the class \"polyp\" had 169 images added. Additionally, the overall size of the Kvasir v2 dataset was expanded from 8000 to 12,000 images.  
As a result of applying both under-sampling and data augmentation techniques to the Kvasir-Capsule dataset, each class in the training set was adjusted to contain 200 images. Consequently, the total size of the training set decreased from 26,453 images to 2800 images. Furthermore, the size of the test set was reduced from 5669 images to 2133 images, and the validation set size was also decreased from 5668 images to 2133 images.