# Investigating Feature Selection and Random Forests for Inter-Patient Heartbeat Classification
## 2 Materials and Methods
### Feature Extraction  
A total of 85 features are considered in this study. Most of them have already found to be relevant in other studies including: beat-to-beat (R-R) intervals (used in almost all previous works), discrete wavelet transform (DWT) coefficients [19; 20; 25], Hermite basis function (HBF) expansion coefficients [21; 22; 23; 24; 25], higher order statistics (HOS) [25; 26; 27], amplitude differences [16; 17], Euclidean distances [16; 17; 25] and temporal characteristics of the ventricular depolarization waves (QRS complex) [19; 28]. We also include features resulting from the normalization of R-R intervals, amplitude differences, and QRS temporal characteristics [16; 19; 28]. Features can be divided into the following groups: \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Dataset** & **NB** & **SVEB** & **VEB** & **FB** & **UB** & **Total** \\ \hline Train (DS1) & 45,866 & 944 & 3788 & 415 & 8 & 51,021 \\ Test (DS2) & 44,259 & 1837 & 3221 & 388 & 7 & 49,712 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Heartbeat distribution by classes of the different divisions used for constructing the train and test sets. The following classes are considered: normal beats (NB), supraventricular ectopic beats (SVEB), ventricular ectopic beats (VEB), fusion beats (FB), and unclassifiable or paced beats (UB). FB and UB classes were not considered in the classification presented in this work but are nevertheless included in the evaluation. * **Heart rate related features (3 features)**: the current R-R interval (\(RR_{0}\)) defined by the heartbeat being classified, the previous R-R interval (\(RR_{-1}\)), and the next R-R interval (\(RR_{+1}\)). R-R intervals are calculated from the location of R spikes provided with the database. * **HBF coefficients (15 features)**: each beat segment, here defined by the samples located 250 ms before and after each R spike, is decomposed using 3, 4, and 5 Hermite functions as described in [21]. The coefficients obtained from fitting Hermite polynomials of degrees 3, 4, and 5 are calculated using the function _hermfit_ provided by the Scikit-Learn package for Python [30]. * **HOS (10 features)**: the third-, and fourth-order cumulant functions (kurtosis and skewness, respectively) for each beat segment are computed. The parameters as defined in [25] are used: the lag parameters range from \(-250\) ms to \(250\) ms centered on the R spike and five equally spaced sample points. * **DWT coefficients (23 features)**: the DWT of each beat segment is computed using the same parameters defined in [25]: the Daubechies wavelet function (db1) is used with three levels of decomposition. * **QRS temporal characteristics (4 features)**: the following temporal characteristics of the QRS complex are calculated: the total duration of the QRS complex (\(QRSw\)), the width of the QRS complex at half of the peak value (\(QRSw2\)), the width of the QRS complex at a quarter of the peak value (\(QRSw4\)), the distance between the peak of the Q wave, and the peak of the S wave (\(Qsd\)). Figure 1 shows an illustration of these features in relation to the ECG signal of a normal heartbeat. A detailed description of the extraction procedure is provided in Appendix A. * **Amplitude differences (8 features)**: the following amplitude difference features as defined in [16] are extracted: the amplitude difference between the P and the Q waves (\(PQa\)), the amplitude difference between the Q and the R waves (\(QRa\)), the amplitude difference between the R and the S waves (\(RSa\)), the distance between the peak of the P wave and the beginning of the QRS complex (\(PRd\)), and the peak value of each of the considered waves (\(Ppeak\), \(Qpeak\), \(Rpeak\), and \(Speak\)). Figure 1 shows an illustration of these features in relation to the ECG signal of a normal heartbeat. A detailed description of the extraction procedure is provided in Appendix A.