## 3 Unbalanced Data Processing Method Based on Oversampling and Undersampling  
Although SMOTE oversampling can generate new samples, it simply interpolates on a few samples and does not take into account the distribution of the surrounding majority samples, which may cause the minority samples to be misclassified as majority samples, and may also increase the overlap problem within the sample set. In contrast, the data-cleaning undersampling method specifically cleans out overlapping data. Therefore, a mixed sampling method is used in this paper, that is, the dataset is oversampled first to increase the number of a few classes, and then the dataset that has completed the oversampling is cleaned to reduce the numbers of most classes. This approach can both balance the dataset and eliminate overlapping data.  
Currently, some popular variants of the mixed resampling method are a combination of SMOTE [20; 21] and ENN [22], and a combination of SMOTE and Tomek Link undersampling. While the Tomek Link and ENN are both algorithms for dealing with unbalanced datasets, their ideas and processings are different [23]. The ENN algorithm eliminates noise  
Figure 2: The GLFC module’s structure.  
and boundary samples by comparing the Euclidean distance between each sample and its \(k\)-nearest neighbor samples. However, in some cases, this approach may over-eliminate noise and boundary samples, resulting in the reduction of a small number of class samples, affecting the performance and accuracy of the classifier. In addition, the effect of the ENN algorithm largely depends on the choice of \(k\) value. If the selected \(k\) value is too small, then the ENN algorithm may ignore some important minority class samples, and if the selected \(k\) value is too large, then the ENN algorithm may include some majority class samples, resulting in the unbalance of the dataset not being solved. On the one hand, the Tomek Link algorithm can retain a few important class samples because the Tomek Link algorithm finds the nearest sample pairs that belong to different classes and then removes most class samples in these sample pairs. On the other hand, the Tomek Link algorithm does not need to explicitly select the \(k\) value because it is a distance-based down-sampling algorithm rather than a neighbor-based algorithm, and it does not need to specify the number of neighbors.  
To sum up, the Tomek Link algorithm has solved the above two problems perfectly, so this chapter adopts the combination of SMOTE and Tomek Link undersampling to solve the problem of piston pump sample imbalance. In the following sections, the process of the hybrid sampling method is described in detail, and its working principle is illustrated by Figure 3.  
1. Randomly select a sample from a minority class and determine \(k\) as the number of nearest neighbor samples. If there is no certainty, then \(k=5\).
2. Select a neighbor of the sample, generate a new composite sample by interpolation, and then add it to a few categories.
3. Repeat step (2) until enough synthetic samples are generated.
4. The Tomek link algorithm is used to detect the distance between two samples to calculate whether they belong to the same category.
5. If there is no other sample of the same class between two samples of different classes, then there is a Tomek link between the two samples. Delete the Tomek link pair.
6. Combine the generated synthetic sample with the original sample retained to obtain a new balanced dataset.  
Figure 3: The SMOTE + Tomek Link sampling flow chart. (**a**) Identify nearest neighbor samples with \(k=5\) around a few class samples, (**b**) synthesize new minority class samples (marked in red box), (**c**) delete the Tomek Link pair to get balanced data, (**d**) and select the Tomek Link pair.