# An Intelligent Heartbeat Classification System Based on Attributable Features with AdaBoost+Random Forest Algorithm

Authors: Runchuan Li; Wenzhi Zhang; Shengya Shen; Jinliang Yao; Bicao Li; Bing Zhou; Gang Chen; Zongmin Wang
Journal: Journal of Healthcare Engineering
 (2021)

---

## Abstract

Arrhythmia is a common cardiovascular disease that can threaten human life. In order to assist doctors in accurately diagnosing arrhythmia, an intelligent heartbeat classification system based on the selected optimal feature sets and AdaBoost + Random Forest model is developed. This system can acquire ECG signals through the Holter and transmit them to the cloud platform for preprocessing and feature extraction, and the features are input into AdaBoost + Random Forest for heartbeat classification. The analysis results are output in the form of reports. In this system, by comparing and analyzing the classification accuracy of different feature sets and classifiers, the optimal classification algorithm is obtained and applied to the system. The algorithm accuracy of the system is tested based on the MIT-BIH data set. The result shows that AdaBoost + Random Forest achieved 99.11% accuracy with optimal feature sets. The intelligent heartbeat classification system based on this algorithm has also achieved good results on clinical data.


---

## Body

## 1. Introduction

In recent years, the incidence rate of cardiovascular diseases is increasing, which seriously threatens human life [1]. Arrhythmia can be divided into two types, life-threatening arrhythmia and nonlife-threatening arrhythmia. Life-threatening arrhythmia can lead to cardiac arrest and sudden death. These patients need urgent treatment. Although nonlife-threatening arrhythmia may not threaten human life immediately, it still needs to be treated timely to avoid further deterioration. Therefore, the intelligent detection and diagnosis of arrhythmia is of great significance for monitoring, preventing the occurrence of heart disease, and improving the work efficiency of doctors.Long-term continuous monitoring [2, 3] of electrocardiogram (ECG) provides valuable information for the prevention of heart attack diseases [4]. Doctors can diagnose the nature of arrhythmia by analyzing the ECG. In order to monitor the nature of abnormal heartbeat, it is necessary to analyze the electrical signal of each heartbeat. However, analyzing long-term ECG records is very time-consuming for doctors. Sometimes, doctors may inevitably make personal mistakes. Therefore, accurate intelligent classification of arrhythmia can improve doctors’ efficiency and reduce the occurrence of misdiagnosis or missed diagnosis [5].This paper presents a heartbeat classification system based on multiple-feature fusion and improved random forest, which can classify arrhythmia from real data collected by the ECG acquisition equipment. This system completely accomplished the process from ECG signal collection to heartbeat classification, and then to present the classification results to doctor. The contribution of this research presented in this paper is as follows:(1)
Developed an intelligent heartbeat classification system from collection, analysis, to result presentation. This system can effectively improve doctors’ work efficiency.(2)
An optimal attributable heartbeat feature set is obtained towards the best possible heartbeat classification system via feature comparison identified through the implementation of multiple classifiers, arrhythmia classification analysis, and feature combination comparison.(3)
After testing, AdaBoost + Random Forest was found to be the best heartbeat classification system. This method can not only deal with input samples with high-dimensional characteristics but also effectively deal with imbalance data classification with random forest approach, which provided an effective method to balance the error of the data set.(4)
The interpretability analysis of the learning content of heartbeat classification system based on AdaBoost + Random Forest algorithm is carried out by constructing feature sets of different ECG prior knowledge and improving the accuracy of heartbeat classification, which has important clinical significance.The rest of this paper is organized as follows: Part 2 briefly introduces the related work. Part 3 provides an over-view of the system architecture. Part 4 details the major process of our system, the algorithm of heartbeat classification. Part 5 presents system performance analysis. Part 6 summarizes the full text.


## 2. Related Work

In the past, the diagnosis of arrhythmia was mainly dependent on the experience of doctors. With the development of artificial intelligence, automatic classification has been applied to various industries in recent years [6–9]. A variety of systems for automatic classification of heartbeat had been proposed by some researchers. These systems can be divided into two types, a classification system based on deep learning and a classification system based on feature engineering.A few systems [10–14] used deep neural network to classify heartbeat, but deep neural networks (DNN) have problems with parameter redundancy. Hilera et al. [15] used ANN to detect arrhythmia to study the usefulness of ANN in clinical diagnosis. But, it is difficult to accurately analyze the performance indicators of neural network using ANN. Li et al. [16] merged the shape and rhythm of the heartbeat into a two-dimensional information vector, and used Convolutional Neural Network to classify the heartbeat. The results show that the system has a better classification effect on v and s categories. Wang et al. [17] proposed a globally updatable classification system in view of the large individual differences and the high cost of marking the ECG icon, which has a good classification effect. The algorithm of heartbeat classification based on deep learning can effectively distinguish between different types of arrhythmias. It is very important for doctors to diagnose diseases, as precise analytical classification can help doctors to accurately diagnose and accurately draw up appropriate treatment plans. However, methods based on deep learning cannot analyze the impact of features on the performance of heartbeat classification.Feature extraction is an important step in the accurate classification of arrhythmia. Over the past few decades, researchers have used a variety of features to automatically classify arrhythmia, including ECG morphology [18, 19], interval [20–23], QRS area [24, 25], wavelet coefficient [26, 27], hermite coefficient [28], and high-order statistics [28, 29]. The relevant features of ECG signals are extracted, and then input into learning algorithms to induce models to classify arrhythmia. At present, machine learning is widely used in medical diagnosis to assist doctors improve the efficiency of diagnosis and treatment. Yildirim [30] uses the wavelet transform method to detect heartbeats in ECG data, and divides these heartbeats into segments according to certain cycles, and then performs multi-resolution wavelet transforms into the segmented signals to obtain different frequencies of the wavelet coefficients, and then develop a heartbeat classification system. The test results confirm the effectiveness of this approach. However, this method only focuses on the features of wavelet coefficients and does not concentrate on other features, which provides a good potential for further improvement. Alickovic and Subasi [31] applied Random Forest to the diagnosis of ECG arrhythmia, using Discrete Wavelet Transform to decompose the ECG signal into different continuous frequency bands, and the purpose of ECG intelligent diagnosis system is to distinguish each kind of heartbeat accurately. The above work has made some achievements in heartbeat classification using morphological features, interval features, QRS wave area, wavelet coefficients, and other aspects, and these intuitive features make full use of the doctor's logical experience and ECG data. There is an expectation in improving heart rate classification accuracy.The project depends on the combination of intuitive attributive features. In order to select the best feature combination, the influence of different feature combinations of heartbeat classification is analyzed. A new heartbeat classification system based on attributable intelligent classification method is presented in this paper. It improves the accuracy of classification and the work efficiency of doctors.


## 3. System Architecture

The fundamental purpose of the ECG intelligent diagnosis system is to distinguish each kind of heartbeat accurately. There is an expectation in improving heart rate classification accuracy. The research value of this project depends on the effective selection and combination of intuitive attributive features, as well as the interpretable reasoning analysis of classification performance. A new heartbeat classification system based on multi-feature fusion and AdaBoost + Random Forest method is presented in this paper. In order to select the best feature combination, the influence of different feature combinations on heartbeat classification is analyzed. The best feature combination is selected and input into AdaBoost + Random Forest for classification. It effectively uses the ECG data and improves the accuracy of classification. The focus of the system is heartbeat classification system based on attributable features and AdaBoost + Random Forest algorithm; the next section will describe the system process in detail. This section introduces the overall structure of the system.The overall architecture of the system is shown in Figure1. It shows that the system components mainly include Holter, smart phones, and soft system. The data collected through Holter is uploaded to the server for analysis. This process requires the user to download the APP on the mobile phone. Before classification, the system automatically extracts features based on denoised ECG data. These features are the best combination of features selected after the test. Compared with other systems, the classification system based on these features makes full and effective use of ECG data and has better interpretability. After classification, the result report will be sent to the patient after being checked by a doctor. Figure 2 is the logical design of the system.Figure 1
The overall architecture of the system.Figure 2
The logic design of the system.Figure3 shows the ECG system function diagram. The system is developed based on Microservice [32], which has better scalability, easy deployment, and low coupling. The holter collects data from the patient and transmits the data to the subject’s mobile phone via Bluetooth. The acquired data are stored in the ECG parameter center on the cloud platform through the http/https protocol, namely, ECGDatabaseGateway Server. The specific transmission, storage, and analysis steps of the collected ECG data on the cloud platform are as follows: ECGDeviceGateway receives and distributes ECG data; ECGDataRouter server realizes the forwarding of ECG data through the subscription-publishing mechanism through NATS. ECGAnalyzeGateway sends the ECG data analysis request to ECGAnalyzeServer that deploys the core algorithm proposed. After receiving the request, ECGAnalyzeServer passes the ECG parameters to the algorithm program for analysis. The transmission uses RPC [33] in order to achieve high transmission efficiency and low performance consumption. The ECGAnalyzeGateway server uses NATS [34] to transmit the analyzed results to the ECGPipeGateway server for real-time transmission during diagnosis. The ECGPipeGateway server displays the results of real-time ECG monitoring on each terminal through the WebSocket protocol [35] that can unilaterally send information to the client, reducing the delay caused by waiting for a reply. At the same time, ECGAnalyzeServer transmits the results to the ECGDataBaseGateway server, which is responsible for storing results of the ECG analysis and classification. Due to the complexity of ECG data, MongoDB [36] is used to store ECG data.Figure 3
The ECG system function diagram.


## 4. System Process

This process uses multi-feature fusion and AdaBoost + Random Forest method to classify heartbeats. It includes ECG signal data, preprocessing, feature extraction, and heartbeat classification. Figure4 shows the framework of heartbeat classification algorithm.Figure 4
The framework of heartbeat classification algorithm.


### 4.1. ECG Signal Preprocessing

In order to classify heartbeat more accurately, it is necessary to denoise the ECG data and detect waveform. The wavelet transform can retain the features and important physiological details of ECG signal, and have a simple calculation process [37]. Therefore, a continuous wavelet is used to remove the original ECG signal noise and detect the boundaries and peak positions of the three waves. In this paper, wavelet transform is a signal time-frequency analysis method [38], which provides time-domain and frequency-domain features. The principle of continuous wavelet transform [39] is shown in formulas (1) and (2). (1) and (2). This paper uses wavelet transform to achieve denoising and R wave detection.(1)Wfa,τ=a−1/2∫−∞+∞ftψt−badt,(2)ψa,τt=a−1/2ψt−ba,a>0,τ∈R.In formula (1), a is the scale factor, and b is the transform factor. Their role is to stretch the basic wavelet function ψt; τ reflects the displacement, and a and τ are continuous variables. The results of CWT can be expressed as functions of scale factor a and transformation factor b. The translation factor enables the wavelet to complete the ergodic analysis along the time axis of the signal. The transform factor can approach different frequency signals in every traversal through scaling wavelet transform.


### 4.2. Heartbeat Feature Extraction and Combination

A complete cardiogram consists of P wave, QRS wave, and T wave. The time interval between the feature points of these waves directly reflects the systolic and diastolic process of heart atrium and ventricle, which is of great value in the diagnosis of heart disease [40]. The extracted ECG features are described as follows:In this paper, the sampling rate is 360 Hz. According to the R peak position, 235 single heartbeat morphological features are extracted [41]. Among them, there are 90 sampling points before the R peak and 144 sampling points after the R peak. If there are less than 235 sampling points before and after the first or last QRS complex is detected in the ECG record file, the corresponding heartbeat is ignored. Each record in the MIT-BIH arrhythmia database contains two leads, of which lead A is lead II and lead B is lead V1. However, in some records, lead B is known to be V2, V5, or V4. According to literature [41, 42], QRS complex is more prominent in lead A, so lead A is usually used to detect heartbeat, lead B has more advantages in distinguishing S and V category arrhythmia. A total of 470 single heartbeat morphological features are obtained from two leads, respectively. Figure 5 shows the two leads in an MIT-BIH arrhythmia database record 210 (10 sec).Figure 5
Example of two leads (II, V1) in an MIT-BIH arrhythmia database record 210 (10 sec).P wave interval, QRS wave interval, T wave interval, PR segment, ST-T interval, QT interval, and RR interval are common features of ECG. The sampling rate (SR) is 360 Hz in this study. Figure6 is the interval diagram of normal heartbeat. The calculation formula is shown in equations (3)– (9):(3)Pwave interval=Pend−PstartSR,(4)QRS wave interval=QRSend−QRSstartSR,(5)Twave interval=Tend−TstartSR,(6)PR segment=QRSstart−PendSR,(7)ST−Tintervel=Tend−QRSendSR,(8)QT interval=Tend−QRSstartSR,(9)RR interval=Rnext peak−Rcurrent peakSR.Figure 6
Interval diagram of normal heartbeat.The QRS complex is the most energetic part of the ECG signal and contains most of the information of the entire heartbeat. The time from the start of the QRS complex to the end of the QRS complex is the QRS time limit, and the QRS wave area is the integral sum of the QRS complex from the start to the end.The QRS complex reflects the changes in left and right ventricular depolarization potentials and time. The first downward wave is the Q wave, the upward wave is the R wave, and the downward wave is the S wave. Therefore, the shape of the QRS complex is mainly considered when selecting the wavelet base. According to the waveform of a cardiac cycle, we choose the db6 wavelet as the wavelet basis function to implement wavelet decomposition [43], because the db6 wavelet has good regularity, which makes the reconstructed signal smooth. The frequency band of QRS complex is generally in the range of 0.5–45 Hz. The wavelet packet decomposition diagram is shown in Figures 7 and 8. Figure 7 shows ECG original signal and its wavelet transform on a 1–6 scale. Figure 8 shows ECG original signal and its wavelet transform on a 7–12 scale. S represents the input ECG signal, A represents the approximation coefficient of the wavelet packet decomposition, and D represents the detail coefficient of the wavelet packet decomposition. In this paper, the wavelet coefficients are extracted as features.Figure 7
The decomposition process of the 12-level wavelet packet (a).Figure 8
The decomposition process of the 12-level wavelet packet (b).In feature engineering, as a single feature cannot fully describe the properties of ECG comprehensively, first-order discrete features are often combined to form high-order combined features, so as to improve the fitting ability of complex relationships. Therefore, the features are divided into five sets, namely, A, B, C, D, and E. Among them, set A and B are morphological features, set C is interval information, set D is area information, and set E is frequency feature. The definition and division of five feature sets are as follows:Set A: {235 single heartbeat morphological features from single lead}Set B: {470 single heartbeat morphological features from double leads}Set C: {P wave interval, QRS wave interval, T wave interval, PR segment, ST-T interval, QT interval, and RR interval}Set D: {QRS area}Set E: {Wavelet coefficient}


### 4.3. AdaBoost + Random Forest Model

AdaBoost ensemble algorithm is an iterative algorithm based on multiple base learners of the same type. The goal of iterative is to form a strong learner [44–46]. The algorithm trains different basic learners on the same training set, changes the weights of samples of iteration, and uses a weighted voting mechanism to stack multiple basic learners, and finally gets the best, strong learner for the overall classification performance.The basic learner of AdaBoost + RF algorithm consists of random forest. Random forest is an important integrated learning method based on bagging. The final prediction result is based on a voting algorithm. Compared with other classification algorithms, random forest algorithm can maintain high accuracy and has good stability [47]. The steps in AdaBoost algorithm are described in Algorithm 1. Figure 9 shows the process of generating the final classifier. Equations (10)–(13) refer to literature [45].Algorithm 1: AdaBoost ensemble algorithm steps.
input: S: A set of original training sets marked with category;M: Number of rounds (number of rounds is the number of classifiers);TheMth round classification is equivalent to the result of the Mth learner classification.Output: Combined classifier model: It contains M classifiers and their voting weights.Procedure:Begin(1)
Initialize the weight of each tuple in S to 1/n;(2)
Form = 1 to M;(3)
According to the weight of tuples, samples are taken froms to get Sm (the Mth training set);(4)
Train theMth classifier according to Sm.(5)
Calculate the error rateem of Mth classifier according to formula (8);(6)
Ifem is greater than 0.5 then;Go to step 3;end if(7)
Calculate the weight of voting right of classifier according to formula (9);(8)
For each correctly classified tuple ofSm, do:Update the weights of correctly classified tuples;Standardize the weight of each tuple.end forend forEndFigure 9
The process of generating the final classifier.In AdaBoost ensemble algorithm, the training data set isX=x1,y1,x2,y2,…,xN,yN, where xi represents the sample point and yi represents the corresponding category of the sample; the importance of the basic classifier Gm depends on its error rate. The error rate em is defined as(10)em=∑j=1NwjICixj≠yj,where xj,yj|j=1,2,…,N represents a set of N training samples. If the predicate P is true, then Ip=1, otherwise 0. The base classifier is defined as(11)αm=12ln1−emem.According to the definition ofαm and em, the lower error rate means that the base classifier is more important. Once the em of a base classifier is higher than 50%, the weight of this round needs to be restored to the initial value and resampled. Update the weight distribution of the training data set:(12)wm+1,i=wm,izmexp−αmyiGmxi,i=1,2,…,N,where zm=∑i=1Nwm,iexp−αmyiGmxi is the gauge factor that makes the sum of all w equal to 1. The final output function is(13)Gx=sign∑m=1MαmGmx.


## 4.1. ECG Signal Preprocessing

In order to classify heartbeat more accurately, it is necessary to denoise the ECG data and detect waveform. The wavelet transform can retain the features and important physiological details of ECG signal, and have a simple calculation process [37]. Therefore, a continuous wavelet is used to remove the original ECG signal noise and detect the boundaries and peak positions of the three waves. In this paper, wavelet transform is a signal time-frequency analysis method [38], which provides time-domain and frequency-domain features. The principle of continuous wavelet transform [39] is shown in formulas (1) and (2). (1) and (2). This paper uses wavelet transform to achieve denoising and R wave detection.(1)Wfa,τ=a−1/2∫−∞+∞ftψt−badt,(2)ψa,τt=a−1/2ψt−ba,a>0,τ∈R.In formula (1), a is the scale factor, and b is the transform factor. Their role is to stretch the basic wavelet function ψt; τ reflects the displacement, and a and τ are continuous variables. The results of CWT can be expressed as functions of scale factor a and transformation factor b. The translation factor enables the wavelet to complete the ergodic analysis along the time axis of the signal. The transform factor can approach different frequency signals in every traversal through scaling wavelet transform.


## 4.2. Heartbeat Feature Extraction and Combination

A complete cardiogram consists of P wave, QRS wave, and T wave. The time interval between the feature points of these waves directly reflects the systolic and diastolic process of heart atrium and ventricle, which is of great value in the diagnosis of heart disease [40]. The extracted ECG features are described as follows:In this paper, the sampling rate is 360 Hz. According to the R peak position, 235 single heartbeat morphological features are extracted [41]. Among them, there are 90 sampling points before the R peak and 144 sampling points after the R peak. If there are less than 235 sampling points before and after the first or last QRS complex is detected in the ECG record file, the corresponding heartbeat is ignored. Each record in the MIT-BIH arrhythmia database contains two leads, of which lead A is lead II and lead B is lead V1. However, in some records, lead B is known to be V2, V5, or V4. According to literature [41, 42], QRS complex is more prominent in lead A, so lead A is usually used to detect heartbeat, lead B has more advantages in distinguishing S and V category arrhythmia. A total of 470 single heartbeat morphological features are obtained from two leads, respectively. Figure 5 shows the two leads in an MIT-BIH arrhythmia database record 210 (10 sec).Figure 5
Example of two leads (II, V1) in an MIT-BIH arrhythmia database record 210 (10 sec).P wave interval, QRS wave interval, T wave interval, PR segment, ST-T interval, QT interval, and RR interval are common features of ECG. The sampling rate (SR) is 360 Hz in this study. Figure6 is the interval diagram of normal heartbeat. The calculation formula is shown in equations (3)– (9):(3)Pwave interval=Pend−PstartSR,(4)QRS wave interval=QRSend−QRSstartSR,(5)Twave interval=Tend−TstartSR,(6)PR segment=QRSstart−PendSR,(7)ST−Tintervel=Tend−QRSendSR,(8)QT interval=Tend−QRSstartSR,(9)RR interval=Rnext peak−Rcurrent peakSR.Figure 6
Interval diagram of normal heartbeat.The QRS complex is the most energetic part of the ECG signal and contains most of the information of the entire heartbeat. The time from the start of the QRS complex to the end of the QRS complex is the QRS time limit, and the QRS wave area is the integral sum of the QRS complex from the start to the end.The QRS complex reflects the changes in left and right ventricular depolarization potentials and time. The first downward wave is the Q wave, the upward wave is the R wave, and the downward wave is the S wave. Therefore, the shape of the QRS complex is mainly considered when selecting the wavelet base. According to the waveform of a cardiac cycle, we choose the db6 wavelet as the wavelet basis function to implement wavelet decomposition [43], because the db6 wavelet has good regularity, which makes the reconstructed signal smooth. The frequency band of QRS complex is generally in the range of 0.5–45 Hz. The wavelet packet decomposition diagram is shown in Figures 7 and 8. Figure 7 shows ECG original signal and its wavelet transform on a 1–6 scale. Figure 8 shows ECG original signal and its wavelet transform on a 7–12 scale. S represents the input ECG signal, A represents the approximation coefficient of the wavelet packet decomposition, and D represents the detail coefficient of the wavelet packet decomposition. In this paper, the wavelet coefficients are extracted as features.Figure 7
The decomposition process of the 12-level wavelet packet (a).Figure 8
The decomposition process of the 12-level wavelet packet (b).In feature engineering, as a single feature cannot fully describe the properties of ECG comprehensively, first-order discrete features are often combined to form high-order combined features, so as to improve the fitting ability of complex relationships. Therefore, the features are divided into five sets, namely, A, B, C, D, and E. Among them, set A and B are morphological features, set C is interval information, set D is area information, and set E is frequency feature. The definition and division of five feature sets are as follows:Set A: {235 single heartbeat morphological features from single lead}Set B: {470 single heartbeat morphological features from double leads}Set C: {P wave interval, QRS wave interval, T wave interval, PR segment, ST-T interval, QT interval, and RR interval}Set D: {QRS area}Set E: {Wavelet coefficient}


## 4.3. AdaBoost + Random Forest Model

AdaBoost ensemble algorithm is an iterative algorithm based on multiple base learners of the same type. The goal of iterative is to form a strong learner [44–46]. The algorithm trains different basic learners on the same training set, changes the weights of samples of iteration, and uses a weighted voting mechanism to stack multiple basic learners, and finally gets the best, strong learner for the overall classification performance.The basic learner of AdaBoost + RF algorithm consists of random forest. Random forest is an important integrated learning method based on bagging. The final prediction result is based on a voting algorithm. Compared with other classification algorithms, random forest algorithm can maintain high accuracy and has good stability [47]. The steps in AdaBoost algorithm are described in Algorithm 1. Figure 9 shows the process of generating the final classifier. Equations (10)–(13) refer to literature [45].Algorithm 1: AdaBoost ensemble algorithm steps.
input: S: A set of original training sets marked with category;M: Number of rounds (number of rounds is the number of classifiers);TheMth round classification is equivalent to the result of the Mth learner classification.Output: Combined classifier model: It contains M classifiers and their voting weights.Procedure:Begin(1)
Initialize the weight of each tuple in S to 1/n;(2)
Form = 1 to M;(3)
According to the weight of tuples, samples are taken froms to get Sm (the Mth training set);(4)
Train theMth classifier according to Sm.(5)
Calculate the error rateem of Mth classifier according to formula (8);(6)
Ifem is greater than 0.5 then;Go to step 3;end if(7)
Calculate the weight of voting right of classifier according to formula (9);(8)
For each correctly classified tuple ofSm, do:Update the weights of correctly classified tuples;Standardize the weight of each tuple.end forend forEndFigure 9
The process of generating the final classifier.In AdaBoost ensemble algorithm, the training data set isX=x1,y1,x2,y2,…,xN,yN, where xi represents the sample point and yi represents the corresponding category of the sample; the importance of the basic classifier Gm depends on its error rate. The error rate em is defined as(10)em=∑j=1NwjICixj≠yj,where xj,yj|j=1,2,…,N represents a set of N training samples. If the predicate P is true, then Ip=1, otherwise 0. The base classifier is defined as(11)αm=12ln1−emem.According to the definition ofαm and em, the lower error rate means that the base classifier is more important. Once the em of a base classifier is higher than 50%, the weight of this round needs to be restored to the initial value and resampled. Update the weight distribution of the training data set:(12)wm+1,i=wm,izmexp−αmyiGmxi,i=1,2,…,N,where zm=∑i=1Nwm,iexp−αmyiGmxi is the gauge factor that makes the sum of all w equal to 1. The final output function is(13)Gx=sign∑m=1MαmGmx.


## 5. System Performance Assessment Analysis

The system test is implemented on Python 3.7 and MATLAB @ R2018b. Gaussian Naive Bayes (GNB), Linear Discriminant Analysis (LDA), Decision Tree (DT), Random Forest model (RF), Gradient Lifting Iterative Decision Tree (GBDT), Support Vector Machine (SVM), and Logistic Regression (LR) are selected for performance comparison. When the data are unbalanced, for the multi-classification problem, the type with a large sample size will have an over-fitting phenomenon during training, and the type with a small sample size will have an under-fitting phenomenon, resulting in false high accuracy of the overall heartbeat classification. This paper deals with data imbalance based on the algorithmic perspective and alleviates the problem of data imbalance by combining AdaBoost and Random Forest. Random Forests are relatively robust to missing data and unbalanced data, and can well predict the effects of up to thousands of variables [48]. The principle is to use small sample sizes in all classifications when generating the training set, and at the same time randomly extract data from the large sample size in the classification to combine with the small sample size to form the training set to obtain multiple training sets and decision tree models. Data imbalance can be effectively alleviated by integrating multiple decision trees. Adaboost can independently and randomly extract several subsets from the majority class, combine each subset with the minority class data to train to generate multiple base classifiers, and then weight them to form a new classifier. In this paper, comparing the performance of multiple classifiers, while considering the characteristics of the classifiers, a random forest is selected as the base classifier. Then, ensemble learning is used to alleviate data imbalance and improve classifier performance. This section mainly describes the test data, evaluation criteria, and presents 16 different test results tested on different sets of data with varied composition of heartbeat features. The results of different test are compared and analyzed. Clinical data are used to verify system performance.


### 5.1. Test Data

In this paper, all the tests are carried out on MIT-BIH arrhythmia database. The MIT-BIH arrhythmia database is a standard database to evaluate arrhythmia detection, and is widely used for algorithm verification. The database contains 48 records from 47 subjects. Each record contains two 30-minute ECG lead signals (lead A and lead B). In 48 records, 23 records included normal sinus rhythm (NSR) and a representative group of conventional arrhythmias; the other 25 records included uncommon but clinically significant cardiac abnormalities [49].According to the ANSI/AAMI EC57 standard proposed by the Association for the advancement of medical instruments (AAMI), there are five categories proposed by AAMI in 2012-specific classification: N (nonectopic beats), S (supraventricular ectopic beats), V (ventricular ectopic beats), F (fusion beats), and Q (unknown beats) [50]. In this paper, 90% data of MIT-BIH arrhythmia database are randomly used for training set and 10% data of MIT-BIH arrhythmia database are used for test set, and there is no intersection between the training data set and test data set. The experimental data statistics can be seen from Table 1. The common heartbeat category example is shown in Figure 10.Table 1
Experimental data statistics.
CategoryTraining setTest setTotalN81,5609,03590,595S2,5282532,781V6,4507857,235F72379802Q7,2487938,041Figure 10
Common heartbeat category example.


### 5.2. Evaluation Measurement

As shown in formulas (14)–(17), TP, FP, TN, and FN need to be calculated in this paper to get the result of heartbeat classification. Among them, TPN represents N category true-positive heartbeat, FPN represents N category false-positive heartbeat, TNN represents N category true-negative heartbeat, and FNN represents N category false-negative heartbeat. The classification results of other categories of heartbeat are calculated in the same way [39]. Table 2 shows the confusion matrix of classification results, where, N, S, V, F, Q represent the real type of heartbeat, and n, s, v, f, q represent the predicted result.(14)TPN=Nn,(15)FPN=Ns+Nv+Nf+Nq,(16)TNN=Ss+Sv+Sf+Sq+Vs+Vv+Vf+Vq+Fs+Fv+Ff+Fq+Qs+Qv+Qf+Qq,(17)FNN=Sn+Vn+Fn+Qn.Table 2
The confusion matrix of classification results.
nsvfqNNnNsNvNfNqSSnSsSvSfSqVVnVsVvVfVqFFnFsFvFfFqQQnQsQvQfQqIn this paper, sensitivity, specificity, positive predictivity, and accuracy are used to evaluate the performance of classifiers [39]. Sensitivity (Se) refers to the proportion of samples judged as positive cases in all positive cases. Specificity (Sp) refers to the proportion of samples judged as negative cases in all negative cases. The positive predictive value (+p) is also known as precision. Accuracy (Acc) is the ratio of correctly classified samples to total samples. The calculation formulas (18)–(21) for the above four evaluation indicators are as follows:(18)Se=TPTP+FN,(19)Sp=TNTN+FP,(20)+p=TPTP+FP,(21)Acc=TP+TNTP+TN+FP+FN.


### 5.3. Test Results of Different Feature Combinations

Feature selection is the most effective way to eliminate irrelevant dimensions. In order to compare the effects of different features on the classification of heartbeat, while ensuring the classification performance of the feature vector, considering the system complexity, this project conducted multiple tests using the set A, B, C, D, E with Adaboost + Random Forest models to select the best combination of features. In total, 16 tests are conducted. Among them, tests (1) –(5) compare the effect of single feature classification; tests (6)–(11) compare the classification effect of the pairwise combination of features; tests (12)–(15) compare the classification effect of three-feature combination; test (16) compares the classification effect of four-feature combination. The final result is that for Adaboost + RF, as the number of feature combinations increases, the accuracy is on the rise. Test (17) compares the performance difference between Adaboost + RF and other base classifiers under different feature combinations.Test (1) conducted heartbeat classification using AdaBoost + Random Forest model with set A. The test is performed on 235 feature points in a single heartbeat. The results show that the average accuracy of classification is 98.59%. Table3 shows the classification results of AdaBoost + Random Forest model tested on the 235 single heartbeat morphological features. Test (2) classified heartbeat based on set B. The results show that the average accuracy of heartbeat classification is 98.84%. Table 4 shows the classification results of the test on the 470 single heartbeat morphological features. Compared with test (1), the results showed that two leads morphology feature is more sufficient than that of the single lead. Test (3) classified heartbeat based on set C. The results show that the average accuracy of classification is 94.37%. But, the sensitivity and positive predictive value of F category are lower. Table 5 shows the classification results of the test on the interval features. The disadvantage of test (3) is that the classification of heartbeat based on interval information alone is not obvious. Test (4) classified heartbeat based on set D. The results show that the sensitivity and positive predictive values of S, V, F, and Q heartbeat are lower, and the average classification accuracy is only 79.92%. Table 6 shows the classification results of the test on the QRS area. The disadvantage of test (4) is that it has poor discrimination only according to QRS area. In test (5), the heartbeat is classified based on set E. The test results show that the sensitivity of S category and F category is low, and the average classification accuracy is 94.68%. Table 7 shows the classification results of the test on the wavelet coefficient. Only using wavelet coefficients cannot describe the heartbeat signal completely, and it is difficult to distinguish the heartbeat with shape close to each other.Table 3
Performance of AdaBoost + Random Forest model tested on set A.
Prediction resultsEvaluation standard (%)nsvfqTPTNFPFNSeSp+pAccN9,03014009,0301,776134599.9492.9898.5398.73S5119910219910,69115478.6599.9999.5099.49V4507391073910,144164694.1499.8497.8899.43F190105005010,86512963.2999.9998.0399.74Q1901077377310,15022097.4899.9899.7499.79Table 4
Performance of AdaBoost + Random Forest model tested on set B.
ResultEvaluation criteria (%)nsVfqTPTNFPFNSeSp+pAccN9,03500009,0351,79311701.093.8798.7298.93S5819500019510,69205877.071.01.099.47V3607490074910,150103695.4199.9098.6899.57F130105605610,86602370.881.01.099.79Q1000078378310,15201098.741.01.099.91Table 5
Performance of AdaBoost + Random Forest model tested on set C.
ResultEvaluation criteria (%)nsvFqTPTNFPFNSeSp+pAccN8,926213611418,9261,45845210998.7976.3395.1894.87S8815660315610,666269761.6699.7585.7198.87V180557822057810,1006020773.6399.4190.5997.56F52081811810,853136122.7899.8858.0699.32Q132010065165110,0876514282.0999.3690.9298.10Table 6
Performance of AdaBoost + Random Forest model tested on set D.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN8,235173226333688,2357641,14680091.1540.0087.7882.22S2023090123010,50518722311.8698.2513.8296.25V339634113863419,81734344443.4496.6249.8592.81F6201124210,81452772.5399.523.7098.82Q54389761391399,68247065417.5395.3722.8289.73Table 7
Performance of AdaBoost + Random Forest model tested on set E.
ResultEvaluation criteria (%)nsVfqTPTNFPFNSeSp+pAccN9,03401009,0341,337573199.9870.0094.4394.76S206470004710,692020618.851.01.098.11V21705680056810,151921772.3699.9198.4497.94F47082402410,86605530.381.01.099.50Q10300069069010,152010387.011.01.099.05Test (6) classified heartbeat based on set B, C. The test results show that the average classification accuracy is 98.97%. Table8 shows the classification results of the test on the 470 single heartbeat morphological features and interval feature. Compared with test (2) and test (3), the sensitivity of S category and F category recognition is improved. In test (7), the heartbeat is classified based on set B, D. The test results show that the average classification accuracy is 98.83%. Table 9 shows the classification results of the test on the 470 single heartbeat morphological features and QRS area. Compared with test (6), it can be seen that the interval features are superior to QRS area information in distinguishing S and F heartbeat types. Test (8) classified heartbeat based on set B, E. The results show that the average classification accuracy is 98.15%. But, the sensitivity of S category and F category is low. They are only 58.49% and 67.09%, respectively. Table 10 shows the classification results of the test on the 470 single heartbeat morphological features and wavelet coefficient. Compared with test (6) and test (7), the deficiency of this feature combination is the lack of interval features, which is an important basis for judging S category and F category of heartbeat. In test (9), the heartbeat is classified based on set C, D. The results show that the average accuracy of classification is 96.59%, but the sensitivity of F category heartbeat is only 39.24%. Table 11 shows the classification results of the test on the interval feature and QRS area. Compared with test (7), it can be seen that it is better to use the 470 single heartbeat morphological features to distinguish F category heartbeat. Test (10) classified heartbeat based on set C, E. The test results show that the average classification accuracy is 98.51%. Table 12 shows the classification results of the test on the wavelet coefficient and interval feature. However, this kind of feature combination cannot effectively distinguish morphologically similar categories of heartbeat, such as N, S category, or V, F category. In test (11), the heartbeat is classified based on set D, E. The results show that the average accuracy of heartbeat classification is 98.24%. Table 13 shows the classification results of the test on the QRS area and wavelet coefficient. Similar to the test (10), this feature combination also cannot effectively distinguish morphologically similar categories of heartbeat.Table 8
Performance of AdaBoost + Random Forest model tested on set B, C.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03500009,0351,80910101.094.7198.8999.08S4920310020310,69205080.241.01.099.54V2907542175410,150103196.0599.9098.7099.63F13095705710,86422272.1599.9896.6199.78Q1000078378310,15201098.741.01.099.91Table 9
Performance of AdaBoost + Random Forest model tested on set B, D.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03410009,0341,796114199.9994.0398.7598.95S5919220019210,69116175.8999.9999.4899.43V3007532075310,149113295.9299.8998.5699.61F15095505510,86422469.6299.9896.4999.76Q1000078378310,15201098.731.01.099.91Table 10
Performance of AdaBoost + Random Forest model tested on set B, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03500009,0351,71819201.089.9597.9298.25S10514800014810,692010558.491.01.099.05V5107331073310,15195293.3799.9198.7899.45F17095305310,86512667.0999.9998.1599.75Q1900077477410,15201997.601.01.099.83Table 11
Performance of AdaBoost + Random Forest model tested on set C, D.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN8,9855264158,9851,6172935099.4484.6696.8496.86S70168150016810,68758566.4099.9597.1199.18V9806830468310,1085210287.0199.4892.9398.59F39093103110,86244839.2499.9688.5799.52Q8602070570510,133198888.9099.8197.3799.02Table 12
Performance of AdaBoost + Random Forest model tested on set C, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,025010009,0251,7791311099.8993.1498.5798.71S5719240019210,69206175.891.01.099.44V3107522075210,130303395.7999.7096.1699.42F150154904910,86423062.0299.9896.0899.71Q2801076476410,15202996.341.01.099.74Table 13
Performance of AdaBoost + Random Forest model tested on set D, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,025010009,0251,7431671099.8991.2598.1898.38S7817410017410,69207968.771.01.099.27V4607381073810,135254794.0199.7596.7299.34F160144904910,86513062.0399.9998.0099.72Q2700076676610,15202796.591.01.099.75Test (12) classified heartbeat based on set B, C, D. The test (12) results show that the average classification accuracy is 99.09%. Table14 shows the classification results of the test on the interval feature, QRS area, and the 470 single heartbeat morphological features. Compared with test (9), the 470 single heartbeat morphological features can effectively improve the overall recognition rate of heartbeat classification. Test (13), heartbeat is classified based on set B, C, E. The average accuracy of this experiment is 99.00%. Table 15 shows the classification results of the test on the 470 single heartbeat morphological features, interval feature, and wavelet coefficient. Compared with test (14), the interval features are slightly better than QRS area in overall classification performance. In test (14), the heartbeat is classified based on set B, D, E. The test (14) results show that the sensitivity of S category and F category heartbeat is not high, and the average accuracy of classification is 98.92%. Table 16 shows the classification results of the test on the 470 single heartbeat morphological features, QRS area, and wavelet coefficient. Compared with test (16), the disadvantage of this experiment is the lack of interval feature, which is an important basis for improving the judgment of heartbeat category. In test (15), the heartbeat is classified based on set C, D, E. The test results show that the average accuracy of classification is 98.44%. Table 17 shows the classification results of the test on the interval feature, QRS area, and wavelet coefficient. Compared with test (16), it is necessary to use the 470 single heartbeat morphological features to distinguish heartbeat categories. In test (16), heartbeat is classified based on set B, C, D, E. The test results show that the average classification accuracy is 99.11%. Table 18 shows the classification results of the test on the 470 single heartbeat morphological features, interval features, QRS area, and wavelet coefficient. All the above experiments show that the optimal feature combination is set B, C, D, E. Figure 11 presents the classification results and performance of the optimal feature combination with AdaBoost + Random Forest model.Table 14
Performance of AdaBoost + Random Forest model tested on set B, C, D.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03023009,0301,82882599.9495.7199.1099.20S4021120021110,69024283.4099.9899.0699.59V2307611076110,145152496.9499.8598.0799.64F110105805810,86512173.4299.9998.3199.80Q800078578510,1520898.991.01.099.93Table 15
Performance of AdaBoost + Random Forest model tested on set B, C, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,02834009,0281,82090799.9295.2999.0199.11S4420720020710,68934681.8299.9798.5799.55V2507600076010,144162596.8299.8497.9499.63F130105515510,86602469.621.01.099.78Q800078578510,1511898.9999.9999.8799.92Table 16
Performance of AdaBoost + Random Forest model tested on set B, D, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,02825009,0281,81199799.9294.8298.9299.03S5619700019710,69025677.8799.9898.9999.47V2107640076410,143172197.3299.8397.8299.65F120125505510,86602469.621.01.099.78Q1000078378310,15201098.741.01.099.91Table 17
Performance of AdaBoost + Random Forest model tested on set C, D, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,02509019,0251,7631471099.8992.3098.8998.56S6418900018910,69206474.701.01.099.42V3607481074810,138223795.2899.7897.1499.46F180115005010,86512963.2999.9998.0499.73Q2902076276210,15113196.0999.9999.8799.71Table 18
Performance of AdaBoost + Random Forest model tested on set B, C, D, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03113009,0311,83779499.9595.8699.1399.24S4320910020910,69114482.6199.9999.5299.58V2007650076510,144162097.4599.8497.9599.67F100125615610,86602370.881.01.099.79Q600078778710,1511699.2499.9999.8799.94Figure 11
Confusion matrix of AdaBoost + Random Forest classification results tested on set B, C, D, E.As the tree (n_estimators) in the random forest of the base classifier is random, different classification results will be produced when different number of parameters are set. Generally, the number of parameters is too small to fit; and the number of parameters is too large to improve the model significantly. Therefore, the parameter selection is very important. Table19 is the classification result using different number of parameters of the optimal feature combination. It can be seen from Table 19 that the performance of the classifier is the best when n_estimators are equal to 70.Table 19
Classification results of different (n_estimators) numbers.
Parameter (n_estimators)2030405060708090Accuracy (%)98.3498.2598.2898.2999.0799.1199.1099.08The purpose of this experiment is to compare the classification performance of multiple classifiers and find that the random forest algorithm has a better recognition effect on the small sample types in the unbalanced experimental data in this article, so the random forest model is used as the basic classifier for AdaBoost ensemble learning. In test (17), the accuracy is used as the evaluation indicator to compare Gaussian Naive Bayes (GNB), Linear Discriminant Analysis (LDA), Decision Tree (DT), Random Forest (RF), Gradient Lifting Iterative Decision Tree (GBDT), Support Vector Machine (SVM), Logistic Regression (LR), and AdaBoost + Random Forest (AdaBoost + RF) model on different feature sets. Table20 presents the classification performance of different classifiers. It can be seen from among them that the LDA model also achieves the best result of 94.38% in set B, C, D, E. DT, RF, SVM, and LR models are based on set B, C, D to achieve the best classification effect. The accuracy is 97.85%, 99.08%, 99.04% and 95.87%, respectively. GNB model achieved the best classification result of 85.39% based on set D, and GDBT model achieved the best classification effect based on set B, C,E. The best classification result is based on AdaBoost + Random Forest model with set B, C, D, E. The average accuracy of the classification is 99.11%. In this paper, after comparing the classification performance of these classifiers under each feature combination, the Random Forest with the best performance is selected as the base classifier for ensemble learning. Tests (1)–(16) are the detailed results of the classification of AdaBoost + Random Forest.Table 20
Accuracy of different classifiers performed with multiple-feature combinations.
Feature setClassifiersABCDEGNBLDALRSVMDTGBDTRFAdaboost + RF∗49.0590.0591.8198.6897.0997.6598.6498.59∗55.8692.7993.9498.9697.7398.3798.9198.84∗82.0682.6982.8591.8991.5191.8394.4594.37∗85.3982.5582.5585.4279.6285.5579.1579.92∗83.0490.1991.8696.8896.4997.6598.1794.68∗∗56.3893.3194.4799.0097.7398.5398.9198.97∗∗69.6392.7793.9298.9697.7898.3999.0298.83∗∗69.1492.7693.9298.5197.4198.5398.9298.15∗∗85.2383.9985.0595.0894.2394.6696.8896.59∗∗84.0992.1993.6097.2596.9898.1498.4398.51∗∗83.0390.2491.8896.9196.6597.6098.1698.24∗∗∗56.6394.1695.8799.0497.8598.6699.0899.09∗∗∗69.6394.1695.8198.6697.7898.7099.0498.99∗∗∗69.0992.9594.0498.5197.2498.4598.8598.92∗∗∗84.0992.2593.6297.2897.0298.1598.4698.44∗∗∗∗69.5994.3895.8298.6697.7398.6499.0099.11


### 5.4. Comparative Results with Other Implemented Classification Methods

The system developed in this paper performs better on classification indicators [43, 51–54]. Table 21 presents comparison with previous studies. Compared with references [21, 55–58], the sensitivity and positive predictive value of N, S, and V heartbeats have been greatly improved. Compared with other methods, the accuracy of heartbeat classification is improved. The experimental results show that the method has the advantages of distinguishing N (nonectopic beats), V (ventricular ectopic beats), and Q (unknown beats). AdaBoost + Random Forest model is used to classify arrhythmia, and an accurate and objective heartbeat analysis system is established.Table 21
Comparison results with other implemented classification methods.
ReferenceFeaturesClassifierPerformanceZhang et al. [21]ECG MorphologyRR intervalSVMAcc = 86.66%Sen = 88.94%; +Pn = 98.98%Ses = 79.06%; +Ps = 35.98%Sev = 85.48%; +Pv = 92.75%Sef = 93.81%; +Pf = 13.73%Ghorbani Afkhami et al. [54]HOSRR intervalDTAcc = 99.70%Sen = 97.37%; +Pn = 98.40%Ses = 86.50%; +Ps = 90.90%Sev = 95.99%; +Pv = 77.63%Sef = 11.86%; +Pf = 24.21%Yang et al. [53]PCAnetLinearSVMAcc = 97.77%+Pn = 98.05%+Ps = 92.80%+Pv = 94.59%+Pf = 91.75%+Pq = 99.50%Wang et al. [43]Medical featuresRFAcc = 99.08%Statistical featuresMorphological featuresJi et al. [56]ECG morphologyFaster R-CNNAcc = 99.21%Se = 98.06%; Sp = 99.45%Sharma et al. [57]Morphological featuresKNNAcc = 98.10%Wavelet transformSen = 99.59%; Spn = 91.92%; +Pn = 98.34%Ses = 73.64%; Sps = 99.84%; +Ps = 92.09%Sev = 92.11%; Spv = 99.75%; +Pv = 96.37%Sef = 64.46%; Spf = 99.94% +Pf = 88.38%Li et al. [58]RR intervalsMorphological featuresCraftNetAcc = 89.25%Sen = 88.16%; Spn = 94.34%Ses = 85.37%; Sps = 94.85%Sev = 94.53%; Spv = 99.70%Sef = 88.92%; Spf = 94.28%ProposedECG morphologyAdaBoost + RFAcc = 99.11%IntervalsSen = 99.95%; Spn = 95.86%; +Pn = 99.13%QRS areaSes = 82.61%; Sps = 99.99%; +Ps = 99.52%Wavelet coefficientsSev = 97.45%; Spv = 99.84%; +Pv = 97.95%Sef = 70.88%; Spf = 100%; +Pf = 100%Seq = 99.24%; Spq = 99.99%; +Pq = 99.87%


### 5.5. Clinical Data Test

In order to verify the actual effect, real data were collected for testing. The disease tag is the result given by the doctor. The format is float, 32 bit binary format, the sampling rate is 1000, and each data have 12 leads. Figure12 is the presented results of the ECG classification. Therefore, this system has evident clinical significance and practical value in the diagnosis of arrhythmia.Figure 12
The result of clinical application of the algorithm.


## 5.1. Test Data

In this paper, all the tests are carried out on MIT-BIH arrhythmia database. The MIT-BIH arrhythmia database is a standard database to evaluate arrhythmia detection, and is widely used for algorithm verification. The database contains 48 records from 47 subjects. Each record contains two 30-minute ECG lead signals (lead A and lead B). In 48 records, 23 records included normal sinus rhythm (NSR) and a representative group of conventional arrhythmias; the other 25 records included uncommon but clinically significant cardiac abnormalities [49].According to the ANSI/AAMI EC57 standard proposed by the Association for the advancement of medical instruments (AAMI), there are five categories proposed by AAMI in 2012-specific classification: N (nonectopic beats), S (supraventricular ectopic beats), V (ventricular ectopic beats), F (fusion beats), and Q (unknown beats) [50]. In this paper, 90% data of MIT-BIH arrhythmia database are randomly used for training set and 10% data of MIT-BIH arrhythmia database are used for test set, and there is no intersection between the training data set and test data set. The experimental data statistics can be seen from Table 1. The common heartbeat category example is shown in Figure 10.Table 1
Experimental data statistics.
CategoryTraining setTest setTotalN81,5609,03590,595S2,5282532,781V6,4507857,235F72379802Q7,2487938,041Figure 10
Common heartbeat category example.


## 5.2. Evaluation Measurement

As shown in formulas (14)–(17), TP, FP, TN, and FN need to be calculated in this paper to get the result of heartbeat classification. Among them, TPN represents N category true-positive heartbeat, FPN represents N category false-positive heartbeat, TNN represents N category true-negative heartbeat, and FNN represents N category false-negative heartbeat. The classification results of other categories of heartbeat are calculated in the same way [39]. Table 2 shows the confusion matrix of classification results, where, N, S, V, F, Q represent the real type of heartbeat, and n, s, v, f, q represent the predicted result.(14)TPN=Nn,(15)FPN=Ns+Nv+Nf+Nq,(16)TNN=Ss+Sv+Sf+Sq+Vs+Vv+Vf+Vq+Fs+Fv+Ff+Fq+Qs+Qv+Qf+Qq,(17)FNN=Sn+Vn+Fn+Qn.Table 2
The confusion matrix of classification results.
nsvfqNNnNsNvNfNqSSnSsSvSfSqVVnVsVvVfVqFFnFsFvFfFqQQnQsQvQfQqIn this paper, sensitivity, specificity, positive predictivity, and accuracy are used to evaluate the performance of classifiers [39]. Sensitivity (Se) refers to the proportion of samples judged as positive cases in all positive cases. Specificity (Sp) refers to the proportion of samples judged as negative cases in all negative cases. The positive predictive value (+p) is also known as precision. Accuracy (Acc) is the ratio of correctly classified samples to total samples. The calculation formulas (18)–(21) for the above four evaluation indicators are as follows:(18)Se=TPTP+FN,(19)Sp=TNTN+FP,(20)+p=TPTP+FP,(21)Acc=TP+TNTP+TN+FP+FN.


## 5.3. Test Results of Different Feature Combinations

Feature selection is the most effective way to eliminate irrelevant dimensions. In order to compare the effects of different features on the classification of heartbeat, while ensuring the classification performance of the feature vector, considering the system complexity, this project conducted multiple tests using the set A, B, C, D, E with Adaboost + Random Forest models to select the best combination of features. In total, 16 tests are conducted. Among them, tests (1) –(5) compare the effect of single feature classification; tests (6)–(11) compare the classification effect of the pairwise combination of features; tests (12)–(15) compare the classification effect of three-feature combination; test (16) compares the classification effect of four-feature combination. The final result is that for Adaboost + RF, as the number of feature combinations increases, the accuracy is on the rise. Test (17) compares the performance difference between Adaboost + RF and other base classifiers under different feature combinations.Test (1) conducted heartbeat classification using AdaBoost + Random Forest model with set A. The test is performed on 235 feature points in a single heartbeat. The results show that the average accuracy of classification is 98.59%. Table3 shows the classification results of AdaBoost + Random Forest model tested on the 235 single heartbeat morphological features. Test (2) classified heartbeat based on set B. The results show that the average accuracy of heartbeat classification is 98.84%. Table 4 shows the classification results of the test on the 470 single heartbeat morphological features. Compared with test (1), the results showed that two leads morphology feature is more sufficient than that of the single lead. Test (3) classified heartbeat based on set C. The results show that the average accuracy of classification is 94.37%. But, the sensitivity and positive predictive value of F category are lower. Table 5 shows the classification results of the test on the interval features. The disadvantage of test (3) is that the classification of heartbeat based on interval information alone is not obvious. Test (4) classified heartbeat based on set D. The results show that the sensitivity and positive predictive values of S, V, F, and Q heartbeat are lower, and the average classification accuracy is only 79.92%. Table 6 shows the classification results of the test on the QRS area. The disadvantage of test (4) is that it has poor discrimination only according to QRS area. In test (5), the heartbeat is classified based on set E. The test results show that the sensitivity of S category and F category is low, and the average classification accuracy is 94.68%. Table 7 shows the classification results of the test on the wavelet coefficient. Only using wavelet coefficients cannot describe the heartbeat signal completely, and it is difficult to distinguish the heartbeat with shape close to each other.Table 3
Performance of AdaBoost + Random Forest model tested on set A.
Prediction resultsEvaluation standard (%)nsvfqTPTNFPFNSeSp+pAccN9,03014009,0301,776134599.9492.9898.5398.73S5119910219910,69115478.6599.9999.5099.49V4507391073910,144164694.1499.8497.8899.43F190105005010,86512963.2999.9998.0399.74Q1901077377310,15022097.4899.9899.7499.79Table 4
Performance of AdaBoost + Random Forest model tested on set B.
ResultEvaluation criteria (%)nsVfqTPTNFPFNSeSp+pAccN9,03500009,0351,79311701.093.8798.7298.93S5819500019510,69205877.071.01.099.47V3607490074910,150103695.4199.9098.6899.57F130105605610,86602370.881.01.099.79Q1000078378310,15201098.741.01.099.91Table 5
Performance of AdaBoost + Random Forest model tested on set C.
ResultEvaluation criteria (%)nsvFqTPTNFPFNSeSp+pAccN8,926213611418,9261,45845210998.7976.3395.1894.87S8815660315610,666269761.6699.7585.7198.87V180557822057810,1006020773.6399.4190.5997.56F52081811810,853136122.7899.8858.0699.32Q132010065165110,0876514282.0999.3690.9298.10Table 6
Performance of AdaBoost + Random Forest model tested on set D.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN8,235173226333688,2357641,14680091.1540.0087.7882.22S2023090123010,50518722311.8698.2513.8296.25V339634113863419,81734344443.4496.6249.8592.81F6201124210,81452772.5399.523.7098.82Q54389761391399,68247065417.5395.3722.8289.73Table 7
Performance of AdaBoost + Random Forest model tested on set E.
ResultEvaluation criteria (%)nsVfqTPTNFPFNSeSp+pAccN9,03401009,0341,337573199.9870.0094.4394.76S206470004710,692020618.851.01.098.11V21705680056810,151921772.3699.9198.4497.94F47082402410,86605530.381.01.099.50Q10300069069010,152010387.011.01.099.05Test (6) classified heartbeat based on set B, C. The test results show that the average classification accuracy is 98.97%. Table8 shows the classification results of the test on the 470 single heartbeat morphological features and interval feature. Compared with test (2) and test (3), the sensitivity of S category and F category recognition is improved. In test (7), the heartbeat is classified based on set B, D. The test results show that the average classification accuracy is 98.83%. Table 9 shows the classification results of the test on the 470 single heartbeat morphological features and QRS area. Compared with test (6), it can be seen that the interval features are superior to QRS area information in distinguishing S and F heartbeat types. Test (8) classified heartbeat based on set B, E. The results show that the average classification accuracy is 98.15%. But, the sensitivity of S category and F category is low. They are only 58.49% and 67.09%, respectively. Table 10 shows the classification results of the test on the 470 single heartbeat morphological features and wavelet coefficient. Compared with test (6) and test (7), the deficiency of this feature combination is the lack of interval features, which is an important basis for judging S category and F category of heartbeat. In test (9), the heartbeat is classified based on set C, D. The results show that the average accuracy of classification is 96.59%, but the sensitivity of F category heartbeat is only 39.24%. Table 11 shows the classification results of the test on the interval feature and QRS area. Compared with test (7), it can be seen that it is better to use the 470 single heartbeat morphological features to distinguish F category heartbeat. Test (10) classified heartbeat based on set C, E. The test results show that the average classification accuracy is 98.51%. Table 12 shows the classification results of the test on the wavelet coefficient and interval feature. However, this kind of feature combination cannot effectively distinguish morphologically similar categories of heartbeat, such as N, S category, or V, F category. In test (11), the heartbeat is classified based on set D, E. The results show that the average accuracy of heartbeat classification is 98.24%. Table 13 shows the classification results of the test on the QRS area and wavelet coefficient. Similar to the test (10), this feature combination also cannot effectively distinguish morphologically similar categories of heartbeat.Table 8
Performance of AdaBoost + Random Forest model tested on set B, C.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03500009,0351,80910101.094.7198.8999.08S4920310020310,69205080.241.01.099.54V2907542175410,150103196.0599.9098.7099.63F13095705710,86422272.1599.9896.6199.78Q1000078378310,15201098.741.01.099.91Table 9
Performance of AdaBoost + Random Forest model tested on set B, D.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03410009,0341,796114199.9994.0398.7598.95S5919220019210,69116175.8999.9999.4899.43V3007532075310,149113295.9299.8998.5699.61F15095505510,86422469.6299.9896.4999.76Q1000078378310,15201098.731.01.099.91Table 10
Performance of AdaBoost + Random Forest model tested on set B, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03500009,0351,71819201.089.9597.9298.25S10514800014810,692010558.491.01.099.05V5107331073310,15195293.3799.9198.7899.45F17095305310,86512667.0999.9998.1599.75Q1900077477410,15201997.601.01.099.83Table 11
Performance of AdaBoost + Random Forest model tested on set C, D.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN8,9855264158,9851,6172935099.4484.6696.8496.86S70168150016810,68758566.4099.9597.1199.18V9806830468310,1085210287.0199.4892.9398.59F39093103110,86244839.2499.9688.5799.52Q8602070570510,133198888.9099.8197.3799.02Table 12
Performance of AdaBoost + Random Forest model tested on set C, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,025010009,0251,7791311099.8993.1498.5798.71S5719240019210,69206175.891.01.099.44V3107522075210,130303395.7999.7096.1699.42F150154904910,86423062.0299.9896.0899.71Q2801076476410,15202996.341.01.099.74Table 13
Performance of AdaBoost + Random Forest model tested on set D, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,025010009,0251,7431671099.8991.2598.1898.38S7817410017410,69207968.771.01.099.27V4607381073810,135254794.0199.7596.7299.34F160144904910,86513062.0399.9998.0099.72Q2700076676610,15202796.591.01.099.75Test (12) classified heartbeat based on set B, C, D. The test (12) results show that the average classification accuracy is 99.09%. Table14 shows the classification results of the test on the interval feature, QRS area, and the 470 single heartbeat morphological features. Compared with test (9), the 470 single heartbeat morphological features can effectively improve the overall recognition rate of heartbeat classification. Test (13), heartbeat is classified based on set B, C, E. The average accuracy of this experiment is 99.00%. Table 15 shows the classification results of the test on the 470 single heartbeat morphological features, interval feature, and wavelet coefficient. Compared with test (14), the interval features are slightly better than QRS area in overall classification performance. In test (14), the heartbeat is classified based on set B, D, E. The test (14) results show that the sensitivity of S category and F category heartbeat is not high, and the average accuracy of classification is 98.92%. Table 16 shows the classification results of the test on the 470 single heartbeat morphological features, QRS area, and wavelet coefficient. Compared with test (16), the disadvantage of this experiment is the lack of interval feature, which is an important basis for improving the judgment of heartbeat category. In test (15), the heartbeat is classified based on set C, D, E. The test results show that the average accuracy of classification is 98.44%. Table 17 shows the classification results of the test on the interval feature, QRS area, and wavelet coefficient. Compared with test (16), it is necessary to use the 470 single heartbeat morphological features to distinguish heartbeat categories. In test (16), heartbeat is classified based on set B, C, D, E. The test results show that the average classification accuracy is 99.11%. Table 18 shows the classification results of the test on the 470 single heartbeat morphological features, interval features, QRS area, and wavelet coefficient. All the above experiments show that the optimal feature combination is set B, C, D, E. Figure 11 presents the classification results and performance of the optimal feature combination with AdaBoost + Random Forest model.Table 14
Performance of AdaBoost + Random Forest model tested on set B, C, D.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03023009,0301,82882599.9495.7199.1099.20S4021120021110,69024283.4099.9899.0699.59V2307611076110,145152496.9499.8598.0799.64F110105805810,86512173.4299.9998.3199.80Q800078578510,1520898.991.01.099.93Table 15
Performance of AdaBoost + Random Forest model tested on set B, C, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,02834009,0281,82090799.9295.2999.0199.11S4420720020710,68934681.8299.9798.5799.55V2507600076010,144162596.8299.8497.9499.63F130105515510,86602469.621.01.099.78Q800078578510,1511898.9999.9999.8799.92Table 16
Performance of AdaBoost + Random Forest model tested on set B, D, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,02825009,0281,81199799.9294.8298.9299.03S5619700019710,69025677.8799.9898.9999.47V2107640076410,143172197.3299.8397.8299.65F120125505510,86602469.621.01.099.78Q1000078378310,15201098.741.01.099.91Table 17
Performance of AdaBoost + Random Forest model tested on set C, D, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,02509019,0251,7631471099.8992.3098.8998.56S6418900018910,69206474.701.01.099.42V3607481074810,138223795.2899.7897.1499.46F180115005010,86512963.2999.9998.0499.73Q2902076276210,15113196.0999.9999.8799.71Table 18
Performance of AdaBoost + Random Forest model tested on set B, C, D, E.
ResultEvaluation criteria (%)nsvfqTPTNFPFNSeSp+pAccN9,03113009,0311,83779499.9595.8699.1399.24S4320910020910,69114482.6199.9999.5299.58V2007650076510,144162097.4599.8497.9599.67F100125615610,86602370.881.01.099.79Q600078778710,1511699.2499.9999.8799.94Figure 11
Confusion matrix of AdaBoost + Random Forest classification results tested on set B, C, D, E.As the tree (n_estimators) in the random forest of the base classifier is random, different classification results will be produced when different number of parameters are set. Generally, the number of parameters is too small to fit; and the number of parameters is too large to improve the model significantly. Therefore, the parameter selection is very important. Table19 is the classification result using different number of parameters of the optimal feature combination. It can be seen from Table 19 that the performance of the classifier is the best when n_estimators are equal to 70.Table 19
Classification results of different (n_estimators) numbers.
Parameter (n_estimators)2030405060708090Accuracy (%)98.3498.2598.2898.2999.0799.1199.1099.08The purpose of this experiment is to compare the classification performance of multiple classifiers and find that the random forest algorithm has a better recognition effect on the small sample types in the unbalanced experimental data in this article, so the random forest model is used as the basic classifier for AdaBoost ensemble learning. In test (17), the accuracy is used as the evaluation indicator to compare Gaussian Naive Bayes (GNB), Linear Discriminant Analysis (LDA), Decision Tree (DT), Random Forest (RF), Gradient Lifting Iterative Decision Tree (GBDT), Support Vector Machine (SVM), Logistic Regression (LR), and AdaBoost + Random Forest (AdaBoost + RF) model on different feature sets. Table20 presents the classification performance of different classifiers. It can be seen from among them that the LDA model also achieves the best result of 94.38% in set B, C, D, E. DT, RF, SVM, and LR models are based on set B, C, D to achieve the best classification effect. The accuracy is 97.85%, 99.08%, 99.04% and 95.87%, respectively. GNB model achieved the best classification result of 85.39% based on set D, and GDBT model achieved the best classification effect based on set B, C,E. The best classification result is based on AdaBoost + Random Forest model with set B, C, D, E. The average accuracy of the classification is 99.11%. In this paper, after comparing the classification performance of these classifiers under each feature combination, the Random Forest with the best performance is selected as the base classifier for ensemble learning. Tests (1)–(16) are the detailed results of the classification of AdaBoost + Random Forest.Table 20
Accuracy of different classifiers performed with multiple-feature combinations.
Feature setClassifiersABCDEGNBLDALRSVMDTGBDTRFAdaboost + RF∗49.0590.0591.8198.6897.0997.6598.6498.59∗55.8692.7993.9498.9697.7398.3798.9198.84∗82.0682.6982.8591.8991.5191.8394.4594.37∗85.3982.5582.5585.4279.6285.5579.1579.92∗83.0490.1991.8696.8896.4997.6598.1794.68∗∗56.3893.3194.4799.0097.7398.5398.9198.97∗∗69.6392.7793.9298.9697.7898.3999.0298.83∗∗69.1492.7693.9298.5197.4198.5398.9298.15∗∗85.2383.9985.0595.0894.2394.6696.8896.59∗∗84.0992.1993.6097.2596.9898.1498.4398.51∗∗83.0390.2491.8896.9196.6597.6098.1698.24∗∗∗56.6394.1695.8799.0497.8598.6699.0899.09∗∗∗69.6394.1695.8198.6697.7898.7099.0498.99∗∗∗69.0992.9594.0498.5197.2498.4598.8598.92∗∗∗84.0992.2593.6297.2897.0298.1598.4698.44∗∗∗∗69.5994.3895.8298.6697.7398.6499.0099.11


## 5.4. Comparative Results with Other Implemented Classification Methods

The system developed in this paper performs better on classification indicators [43, 51–54]. Table 21 presents comparison with previous studies. Compared with references [21, 55–58], the sensitivity and positive predictive value of N, S, and V heartbeats have been greatly improved. Compared with other methods, the accuracy of heartbeat classification is improved. The experimental results show that the method has the advantages of distinguishing N (nonectopic beats), V (ventricular ectopic beats), and Q (unknown beats). AdaBoost + Random Forest model is used to classify arrhythmia, and an accurate and objective heartbeat analysis system is established.Table 21
Comparison results with other implemented classification methods.
ReferenceFeaturesClassifierPerformanceZhang et al. [21]ECG MorphologyRR intervalSVMAcc = 86.66%Sen = 88.94%; +Pn = 98.98%Ses = 79.06%; +Ps = 35.98%Sev = 85.48%; +Pv = 92.75%Sef = 93.81%; +Pf = 13.73%Ghorbani Afkhami et al. [54]HOSRR intervalDTAcc = 99.70%Sen = 97.37%; +Pn = 98.40%Ses = 86.50%; +Ps = 90.90%Sev = 95.99%; +Pv = 77.63%Sef = 11.86%; +Pf = 24.21%Yang et al. [53]PCAnetLinearSVMAcc = 97.77%+Pn = 98.05%+Ps = 92.80%+Pv = 94.59%+Pf = 91.75%+Pq = 99.50%Wang et al. [43]Medical featuresRFAcc = 99.08%Statistical featuresMorphological featuresJi et al. [56]ECG morphologyFaster R-CNNAcc = 99.21%Se = 98.06%; Sp = 99.45%Sharma et al. [57]Morphological featuresKNNAcc = 98.10%Wavelet transformSen = 99.59%; Spn = 91.92%; +Pn = 98.34%Ses = 73.64%; Sps = 99.84%; +Ps = 92.09%Sev = 92.11%; Spv = 99.75%; +Pv = 96.37%Sef = 64.46%; Spf = 99.94% +Pf = 88.38%Li et al. [58]RR intervalsMorphological featuresCraftNetAcc = 89.25%Sen = 88.16%; Spn = 94.34%Ses = 85.37%; Sps = 94.85%Sev = 94.53%; Spv = 99.70%Sef = 88.92%; Spf = 94.28%ProposedECG morphologyAdaBoost + RFAcc = 99.11%IntervalsSen = 99.95%; Spn = 95.86%; +Pn = 99.13%QRS areaSes = 82.61%; Sps = 99.99%; +Ps = 99.52%Wavelet coefficientsSev = 97.45%; Spv = 99.84%; +Pv = 97.95%Sef = 70.88%; Spf = 100%; +Pf = 100%Seq = 99.24%; Spq = 99.99%; +Pq = 99.87%


## 5.5. Clinical Data Test

In order to verify the actual effect, real data were collected for testing. The disease tag is the result given by the doctor. The format is float, 32 bit binary format, the sampling rate is 1000, and each data have 12 leads. Figure12 is the presented results of the ECG classification. Therefore, this system has evident clinical significance and practical value in the diagnosis of arrhythmia.Figure 12
The result of clinical application of the algorithm.


## 6. Conclusion

A novel, effective system of arrhythmia classification based on multi-feature fusion with optimal feature selection using AdaBoost + Random Forest model is presented in this paper. Based on this system, doctors can check the similarity and difference in features through machine learning model. The classification system of arrhythmia proposed in this paper has high recognition rate and is of great significance in clinical application. Although cardiac classification has made significant progress in the diagnosis of cardiovascular diseases, the sensitivity of this method of S and F category heartbeat needs to be improved. In order to achieve better classification effect, the future research will focus on improving the recognition performance of S and F category heartbeat.Highlights of this paper are as follows:(1)
This system accomplished automation from ECG signal collection, intelligent analysis to result presentation, thereby effectively improving the efficiency of doctor’s diagnosis.(2)
In the case of unbalanced ECG data set, a novel AdaBoost + Random Forest approach is proposed for the heartbeat classification system.(3)
The framework is used to learn the potential correlation between an individual heartbeat internal data and the relationship of the different individual heartbeats.(4)
Among a total 8 of classifiers examined, the AdaBoost + Random Forest is capable of achieving the best on the obtained optimal feature set.



---

*Source: 9913127-2021-07-12.xml*