# A New Image Oversampling Method Based on Influence Functions and Weights
## 3 The Proposed IFW-SMOTE
### Algorithm Description and Mechanism Discussion  
IFW-SMOTE consists of three phases: screening, synthesis, and filtering. The main methods used are influence function, feature extraction model, SMOTE random interpolation, and image reduction module. The pseudo-code of IFW-SMOTE is summarized in Algorithm 1.  
```
Input: Initial \(D=(X,Y)\) Output: Final synthesized image dataset \(DF=(X,Y)\)
1. Initial image sample selection  Calculate the loss of the output data: \(L(y_{i},f(x,\theta))=-\sum y_{i}\log f(x_{i})\).  Based on ERM: calculate \(\hat{\theta}=\arg\min_{\theta}\frac{1}{n}\sum_{i=1}^{n}L(y_{i},f(x_{i}; \theta))\).  The sample weights are increased by \(\varepsilon\), calculate: \(\hat{\theta}=\arg\min_{\theta}\frac{1}{n}\sum_{i=1}^{n}L(y_{i},f(x_{i}; \theta))\).  Compute the Hessian matrix: \(H=\frac{1}{n}\cdot\sum\
abla_{\theta}^{2}L(y_{i},f(x_{i},\theta))\).  Calculating the effect of samples on model parameters: \(I(x;\theta)\)  Calculate the sample score: \(IFW(x_{i})=I(x_{i},\theta)w_{i}\).  Sample Filtering: \(IFW(x_{i})<\delta\)
```  
**Algorithm 1** IFW-SMOTE  
In order to improve the quality, diversity, and randomness of the synthesized image, in the article, we choose the SMOTE scheme to realize the synthesis of image features and the generative module of DCGAN to reduce the features to images. The mechanism of the whole process is as follows. First, each sample category in the dataset is obtained, and the minority category is obtained by calculating the sample imbalance ratio IR. For each sample in the minority category, we calculate the relationship between the change in model parameters and the change in training sample weights through the influence function to obtain the influence value of the sample, combine the influence value with the sample weights linearly to obtain the sample score, and filter the minority category samples in the range of mean plus two times the variance and minus two times the variance by calculating the mean and variance of the sample score. The screened minority class images are used as input to the feature extraction model to extract image features for each minority class. We randomly select a minority class image feature as the initial sample, find the five nearest neighbor image features of that sample, and randomly choose one of these five image features as the closest neighbor sample. Randomly generating image features between the initial and nearest-neighbor samples ensures the randomness of the synthesized images, which prevents the generated images from leading to overfitting of the model, thus increasing the generalization ability of the model. Next, the synthesized image features are used as inputs to the DCGAN generation module instead of random noise, which is designed to effectively prevent the generation of noisy samples and thus synthesize more realistic images. For these synthesized minority class samples, we need to screen them further, and the screening method is the same as the previous method of initial sample selection. After these three steps, we believe that the synthesized images are more realistic, and at the same time, the image quality is higher, which can effectively improve the training effect of the model.