# Research on ECG Signal Classification Based on Hybrid Residual Network
## 2 Method
### Oversampling  
The MIT-BIH dataset exhibits a strong imbalance in the distribution of cardiac disease categories, with normal heartbeats occurring approximately nine times more frequently than other categories. In these instances, machine learning methods encounter challenges when dealing with imbalanced class distributions. To rectify the issue of data imbalance, we employed the SMOTE (Synthetic Minority Oversampling Technique) algorithm in this study. This algorithm generates new synthetic data by analyzing the similarities among existing data samples, thereby balancing the class distribution.  
The core idea of the SMOTE algorithm is to generate new minority class instances using linear interpolation of the existing minority class instances. Specifically, a minority class sample \(x_{i}\) is randomly selected, followed by the identification of its k-nearest neighbors, from which one nearest neighbor \(x_{i,k}\) is randomly chosen. A random number \(\lambda\), ranging from 0 to 1, is subsequently generated, and the vector between the two samples is scaled using this random number:  
\[x_{\text{new}}=x_{i}+\lambda\cdot(x_{i,k}-x_{i}) \tag{4}\]  
By using this method, the SMOTE effectively increases the number of minority class samples, alleviating the issue of class imbalance.  
We partitioned the dataset into 10 equal-sized subsets, preserving a 9:1 ratio between the training and the test sets. In this process, 9 of the subsets were used to train the model, while the remaining subset was used for the final test evaluation. Applying 10-fold cross-validation, we thoroughly evaluated the model's performance and ensured the use of independent test data for the precise calculation of evaluation metrics, thereby enhancing the reliability of the results and the overall accuracy of the model. From the training set in each fold, 10% of the data were further reserved as a validation set to tune model parameters and prevent overfitting. This procedure ensured that the test set remained completely independent during the training and validation phases, providing an unbiased evaluation of the model's performance.  
To avoid affecting the evaluation of the test set, oversampling was restricted to the training set. Due to the limited quantity of F-class and S-class samples in the MIT-BIH dataset, the model may exhibit bias towards categories with a greater number of samples. Therefore, we employed the SMOTE algorithm to oversample the minority classes. The sample sizes for each category after oversampling are displayed in Table 2. Specifically, \"Samples in the origin dataset\" represents the total number of heartbeat samples extracted from the MIT-BIH dataset for each class. \"Training samples\" indicates the number of samples allocated to the training set after splitting the dataset into a 9:1 ratio, with the remaining samples assigned to the test set. \"Training samples after SMOTE\" shows the updated sample counts for each class after applying the SMOTE algorithm, where the F-class samples increased from 730 to 6000 and the S-class samples from 2483 to 6000. The sample sizes of other classes remained unchanged to maintain their original distribution. \"Testing samples\" displays the sample counts allocated to the test set, which remained unaltered to ensure the objectivity and consistency of performance evaluation.