# Adversarial Validation in Image Classification Datasets by Means of Cumulative Spectral Gradient
## 3 Materials and Methods
### Adversarial Validation  
In order to perform the adversarial validation, the data of a class of the dataset are compared against data that, in principle, belong to the same class. This evaluation is performed by applying the CSG metric presented in Section 2, and although the calculation of the CSG metric is based on all the steps described in that section, in the end, it is only necessary to establish two main parameters: the number of samples selected per class (\(M\)), and the number of neighbors in the K-nearest estimator (\(K_{C}\)), given in Equation (3). The fit of these values is straightforward, and in our case, 250 and 20, respectively, were used for the three datasets used. Consequently, if the data show similar characteristics (they come from similar distributions), a high metric value will be obtained; otherwise, the CSG value will be low (high separability between data of the \"same\" class).  
The process carried out to perform the adversarial validation between the original datasets presented in Section 3.1 and the modified versions of these datasets was carried out both at the class and the corruption level. The stages of the adversarial validation process are described as follows, and Figure 4 shows the corresponding flowchart diagram:  
* Stage 1: Data Selection.Selecting a class from the original train dataset (referred to as Set X) and the corresponding class from the modified test dataset which has undergone a specific type of corruption (referred to as Set Y).
* Stage 2: Class-level Adversarial Validation. Compute the CSG metric between Set X and Set Y, as described in Section 2. Since the data belong to the same class, the metric allows estimating the degree of distribution shift of the modified data with respect to the original training data. If the two sets have a similar distribution, the data are hardly separable, so a high CSG value (close to 1) is obtained. Conversely, a low CSG value (close to zero) indicates that data of the same quality (original and corrupted) are easily separable.
* Stage 3: Dataset-Level Adversarial Validation. Stages 1-2 are repeated for each of the classes of each of the corrupted datasets to be evaluated.
* Stage 4: Corruption-level Adversarial Validation. Finally, stages 1-3 are applied for each of the corruptions of the evaluated datasets.  
In addition, as a benchmark, the comparison is also performed against the original (unmodified) test dataset. Thus, for the MNIST dataset, 160 validations (10 classes \(\times\) (15 manipulation types + 1 original test data)) were performed. For the CIFAR-10 dataset, 200 validations were performed (10 classes \(\times\) (19 types of manipulation + 1 original test  
Figure 4: Flowchart diagram of the adversarial validation methodology. The blue lines represent the original datasets, and the red line represents the corrupted datasets.  
data))), whereas for the CIFAR-100 dataset, 2000 validations were performed (100 classes \(\times\) (19 types of manipulation + 1 original test data)).  
Thus, following the stages shown in Figure 4, the adversarial validation process systematically assesses the similarity and separability of data within the same class across original and corrupted versions of the datasets. This comprehensive assessment helps to understand the impact of different types of corruption on data integrity and possible changes in data distribution over time.