## 3 Materials and Methods
### Data Preprocessing  
Our hybrid residual/inception-based deep model (HRIDM) machine learning strategy for classifying ECG signals focuses on various preprocessing approaches. Our ECG dataset from PhysioNet is large and diverse, with recordings of different lengths and sizes (42,720). Hence, preprocessing is essential to prepare the data for useful analysis. We use Algorithm 1's multi-step preprocessing approach to make sure the data are standardized and appropriate for use in machine learning models. In order to provide effective training, this iterative method serves as a generator function, continuously producing batches of features and labels. Figure 1: Data distribution based on signal length. Figure 2: Distribution of ECG signals across 27 diagnosis categories. ```
Initialization: \(\{gen_{x}:\text{Generator for features},gen_{y}:\text{Generator for labels},X_{train}:\text{Status result},\)\(y_{train}:\text{Database}\}\) Input: \(\{gen_{x},gen_{y},X_{train},y_{train}\}\) Output: \(\{X_{batch},y_{batch}\}\)
#Step 1: Initialize Parameters and Data Structures Set batch_size Create order_array
#Step 2: Generate Batches While True :  Initialize empty arrays for \(batch\_features,batch\_labels\) For each batch :  For \(i\) in range \(batch\_size:\) \(batch\_features[i]=next(gen_{x})\) \(batch\_labels[i]=next(gen_{y})\) \(X_{normalized}=\frac{batch\_features-X_{batch\_features}}{\text{$y_{ batch\_features}$}}\) \(Yield(X_{normalized},batch\_labels)\)
#Step 3: Shuffle Labels While True :  For \(i\) in order_array :  Yield \(shuffled\) labels : \(\left(y_{shuffled}=y_{train}[i]\right.\)
#Step 4: Preprocess Features While True: For \(i\) in order_array :  Load and preprocess feature data: \(data,header\_data=load\_data(X_{train}[i])\) \(X_{train\_padded}=\text{pad\_sequences}\left(data,maxlen=5000,truncating=^{`}pos^{i}, padding=^{`}pos^{i}\right)\) \(X_{train\_resolved}=X_{train\_padded}.\text{reshape}(5000,12)\) \(X_{train\_resolved\_normalized}=\frac{X_{train\_robust}-X_{train\_robust}}{ \text{$y_{train\_resolved}$}}) Yield(X_{train\_new\_normalized})
```  
**Algorithm 1** Data preprocessing algorithm utilized for ECG data. The basic idea behind Algorithm 1 is the designation of a batch size, which establishes how many data points are processed simultaneously during training. Additionally, in order to prevent the model gaining biases from the original recording sequence, we shuffle the order of the training data points. Several generator functions retrieve features and labels for each data point inside each batch, most frequently by gaining access to external data sources. On the obtained features, we apply normalization to compensate for possible differences in signal strength between recordings. By scaling the features to a particular range (often between 0 and 1) based on the mean and standard deviation of the current batch, this normalization makes sure that each feature contributes equally during the training process [34]. Another loop shuffles the labels in the training set while batch generation is taking place. By preventing the model from picking up possible dependencies based on the initial label order, this step eventually enhances the model's capacity to generalize to unseen inputs. Preparing each individual feature is an additional vital component of preprocessing; this is achieved via an additional loop that iterates over the shuffled order array. Here, we use the current index in the order array to access a particular training data point, which is a raw ECG signal [35; 36]. Using zeros as padding ensures that all of the input data points have the same format. This is required if the duration of the recovered ECG signal is less than the required input size, which is usually 5000 samples. The data are then rearranged into a two-dimensional structure with 12 columns (representing the 12 ECG leads) and 5000 rows (representing time samples) after padding.