Design of A Hybrid Model For Cardiac Arrhythmia Classification Based On Daubechies Wavelet Transform
Design of A Hybrid Model For Cardiac Arrhythmia Classification Based On Daubechies Wavelet Transform
A – research concept and design; B – collection and/or assembly of data; C – data analysis and interpretation;
D – writing the article; E – critical revision of the article; F – final approval of the article
Advances in Clinical and Experimental Medicine, ISSN 1899–5276 (print), ISSN 2451–2680 (online) Adv Clin Exp Med. 2018;27(6):727–734
Conflict of interest Material and methods. The design phase of the classification model comprises the following stages:
None declared preprocessing of the cardiac signal by eliminating detail coefficients that contain noise, feature extrac-
tion through Daubechies wavelet transform, and arrhythmia classification using a collaborative decision
Acknowledgements from the K nearest neighbor classifier (KNN) and a support vector machine (SVM). The proposed model
The authors express their sincere and heartfelt
thanks to the management and to the principal is able to classify 5 arrhythmia classes as per the ANSI/AAMI EC57: 1998 classification standard. Level 1
of PSG College of Technology, Coimbatore of the proposed model involves classification using the KNN and the classifier is trained with examples
for extending the essential support and
infrastructure to carry out this work.
from all classes. Level 2 involves classification using an SVM and is trained specifically to classify overlapped
classes. The final classification of a test heartbeat pertaining to a particular class is done using the proposed
KNN/SVM hybrid model.
Received on March 16, 2016 Results. The experimental results demonstrated that the average sensitivity of the proposed model was
Reviewed on August 17, 2016
Accepted on February 14, 2017
92.56%, the average specificity 99.35%, the average positive predictive value 98.13%, the average F-score
94.5%, and the average accuracy 99.78%.
Conclusions. The results obtained using the proposed model were compared with the results of discriminant,
tree, and KNN classifiers. The proposed model is able to achieve a high classification accuracy.
Key words: support vector machine, biomedical data classification, decision support systems
DOI
10.17219/acem/68982
Copyright
Copyright by Author(s)
This is an article distributed under the terms of the
Creative Commons Attribution Non-Commercial License
(http://creativecommons.org/licenses/by-nc-nd/4.0/)
728 R. Rajagopal, V. Ranganathan. A model for cardiac arrhythmia classification
Table 1. Number of heartbeats in each class respectively, and are the outputs of the high pass and low
Heartbeat type N S V F Q pass filters after sub-sampling by 2. This procedure is re-
Full database 87643 2646 6792 794 15 peated until the required decomposition level is reached.
The low frequency component is called approximation and
N − non-ectopic beat; S − supra-ventricular ectopic beat; V − ventricular
the high frequency component is called detail.
ectopic beat; F − fusion beat; Q − unknown beat.
In this work, the raw ECG signals sampled at 360 Hz
were decomposed into approximation and detail sub
bands up to level 9 using Daubechies (‘db8’) wavelet basis
function.18 The first and second level detail coefficients
were made zero and were not used for reconstruction
of the denoised signal, since most of the ECG informa-
tion is contained within the 40-Hz frequency range and
sub bands at the first and second levels contain the fre-
quency ranges 90–180 Hz and 45–90 Hz, respectively.
Moreover, power line interference noise occurs at 50 Hz
or 60 Hz. Baseline wander noise occurs in the frequency
range of <0.5 Hz, and therefore, the level 9 approxima-
tion sub band in the frequency range of 0–0.351 Hz was
not used for reconstruction. The denoised signal was
obtained by applying inverse DWT to the required detail
coefficients of levels 3, 4, 5, 6, 7, 8, and 9. The coefficients
of detail sub bands 1 and 2 and the approximation sub
band 9 were made 0.
After denoising, the continuous ECG waveform was
segmented into individual heartbeats. This segmentation
is done by identifying the R peaks using the Pan-Tompkins
algorithm and by considering the 99 samples before the R
peak and the 100 samples after the R peak.19 This choice
of 200 samples, including the R peak for segmentation,
was made because it constitutes one cardiac activity with
P, QRS, and T waves. Figure 2 shows a segment of a re-
corded ECG waveform of patient No. 123 before and after
preprocessing.
Fig. 1. Architecture of the proposed work
Feature extraction
The entire database (97,890 heartbeats) is divided into
Data preprocessing 10 sets, each containing 9,789 heartbeats. Nine sets are
used for training (88,101 heartbeats) and 1 set for testing
The records contain continuous ECG recordings of a du- (9,789 heartbeats). From each heartbeat, wavelet-based
ration of 30 min. The raw ECG signals include baseline features are extracted by using Daubechies wavelet
wander, motion artifact, and power line interference noise. (‘db4’). A Daubechies wavelet with level 4 decomposi-
The discrete wavelet transform (DWT) is used for denois- tion was selected in this project after making perfor-
ing the ECG signal and for extracting the important fea- mance comparisons with a discrete Meyer wavelet and
tures from the original ECG signal.22,27 The DWT cap- other levels of Daubechies wavelets, including ‘db2’ and
tures both temporal and frequency information. The DWT ‘db6’. A total of 107 features were produced by the 4 th
of the original ECG signal is computed by successive high level approximation sub-band and another 107 features
pass and low pass filtering of that signal. This can be math- by the 4 th level detail sub-band. Principal component
ematically represented as follows in equations (1) and (2), analysis (PCA) was applied to reduce redundant informa-
tion on the extracted features and to reduce the dimen-
(1) y high [k] = n = x[n] g[2k n] sionality. After dimensionality reduction was applied
separately to the approximation and detail sub-bands,
(2) y low [k] = n = x[n] h[2k n] a total of 12 features were obtained. The choice of 6 fea-
tures from each sub-band was made since there is no sig-
where x[n] is the original ECG signal samples, g and h are nificant improvement in classification when more than
the impulse responses of the high pass and low pass filters, 6 features are used.
730 R. Rajagopal, V. Ranganathan. A model for cardiac arrhythmia classification
Training of classifiers and many class S samples are wrongly predicted as class N
at level 1 because of the large number of class N training
The training and testing matrix was computed, in which examples (87,643 × 12). More weight is given to a decision
each row represents an ECG heartbeat and the features oc- from the SVM classifier while determining a test heartbeat
cupy the columns. The KNN (with distance metrics such to be other than class S. The advantage of the SVM classifier
as Euclidean, correlation, Mahalanobis, standardized Euclid- is that it performs well on datasets that have many attributes,
ean, and Spearman), tree, and discriminant (linear and qua- even when there are few training examples available. But
dratic) classifiers are trained with a training matrix 88,101 × the drawback of SVM is its limitation in speed and size during
12 in size, which includes training examples from all 5 classes. both training and testing. Because of this limitation, SVM
The sensitivity, specificity, accuracy, positive predictivity, and is not used for the training and classification of all classes.
F-score of those classifiers in classifying ECG arrhythmias SVM is used only to make a final decision of a highly over-
were compared. The classifier that produced the best sensitiv- lapped minority class. A description of the classifiers used
ity and F-score was selected at level 1 of the proposed model. is discussed in the following sections.
The radial basis function SVM was used at level 2 of the pro-
posed model and was trained with examples from the entire K nearest neighbor classifier
class S and down-sampled examples from class N. Random
down-sampling of class N is done in order to match the sam- KNN is an instance-based simple classification algo-
ple size of class S (2,646 × 12). The reason for this design rithm. For a training data set of N points and its cor-
is that samples from classes S and N are highly overlapped responding labels, given by {(x1, y1), (x 2 , y2)… (x N, yN)},
Adv Clin Exp Med. 2018;27(6):727–734 731
where (xi, yi) represents a data pair ‘i’ with ‘xi ’ as the input training example, where xi is the input vector for the ith ex-
feature vector and ‘y i ’ as its corresponding target class ample and di is its corresponding target output, αi is the ith
label, the most likely class of test beat ‘x’ is determined Lagrange multiplier, K(x, x i) is the inner product kernel,
by finding the K closest training points to it. The predic- and b is the bias, then the optimal separating hyper plane
tion of a class is determined by majority vote. The distance is defined as in Equation (3):
is taken as the weighting factor for voting. The main ad-
vantage in selecting the KNN classifier is that complex (3) f(x) = ∑ N
i=1 a1 d1 K (x , xi ) + b
tasks can be learned using simple procedures by local ap-
proximation. The training process for KNN only consists A radial basis function SVM was used in this work in-
of storing feature vectors and their corresponding labels. stead of polynomial and two-layer perceptron because
It also works well on classes with different characteristics of its higher discrimination ability. The inner product ker-
for different subsets.20 nel K(x, xi) of a radial basis function with width σ is given
by equation (4):
Tree-based classifier
−1
(4) K (x , xi ) = exp( x − xi2 )
2ˆ 2
The decision tree algorithm works by selecting the best
attribute to split the data and expand the leaf nodes The performance of the proposed model was evaluated
of the tree until the stopping criterion is met. After build- using performance metrics such as sensitivity, specificity,
ing the tree, tree pruning is performed to reduce the size positive predictivity, F-score, and accuracy. These met-
of the decision tree. This is done in order to avoid over- rics are computed by calculating true positive (TP), true
fitting and to improve the generalization capability of de- negative (TN), false positive (FP), and false negative (FN)
cision trees. The class of a test heartbeat is determined counts and are defined as follows: sensitivity = TP / (TP
by following the branches of the tree until a leaf node + FN), specificity = TN / (TN + FP), positive predictiv-
is reached. The class of that leaf node is then assigned ity = TP / (TP + FP), F-score = 2TP / (2TP + FP +FN), and
to the test heartbeat. The advantage of this algorithm is its accuracy = (TP + TN) / (TP + FP + FN +TN). The process
simplicity and good performance for larger data sets. Gini’s is repeated 10 times so that each set is used once for test-
diversity index is used as the split criterion in this work. ing. The overall performance of the classifier is computed
by taking the average of all 10 folds.
Discriminant classifier
The algorithm creates a new variable from one or more Results and discussion
linear combinations of input variables. Linear discrimi-
nant analysis is done by calculating the sample mean The reliability of a classifier in accurately predicting
of each class. Sample covariance is calculated by sub- the test heartbeat’s class is measured mainly by the sen-
tracting the sample mean of each class from the observa- sitivity and F-score. The reason for not considering accu-
tions of that class, and taking the empirical covariance racy is that even a poor classifier can show good accuracy
matrix of the result. In the linear discriminant model, only in favoring a class with more training examples. It can be
the means vary for each class, but the covariance matrix observed from Fig. 3 that a discriminant classifier with
remains the same. For quadratic discriminant analysis, linear and quadratic function produces consistently less
both the mean and covariance of each class varies. sensitivity than KNN and tree classifiers. The KNN with
Euclidean distance metric produces the highest sensitivity.
Support vector machine Figure 4 shows the specificity of all classifiers in each
of the 10 folds. The discriminant classifier produces
The support vector machine (SVM) constructs a hyper the least specificity. The KNN classifier produces the high-
plane in such a way that the margin of separation between est specificity. Figure 5 shows the F-score of all classifiers
positive examples (minority class S) and negative exam- in all 10 folds. The discriminant classifier with a linear
ples (majority class N) is maximized. Since classes S and function produces the lowest F-score. The tree classifier
N overlap very much, the hyper plane cannot be linearly and the quadratic discriminant classifier produce a near-
separable and cannot be constructed without a classifica- ly uniform F-score, while the KNN classifier achieves
tion error. For such overlapped patterns, SVM performs the highest F-score.
nonlinear mapping of the input vector into a high dimen- The KNN with Euclidean distance metric achieves
sional feature space. An optimal hyper plane is constructed the highest accuracy compared to other classifiers and
for separation of these newly mapped features. The hy- is shown in Fig. 6.
per plane is constructed in such a way that it minimizes Table 2 shows the average classification results of all clas-
the probability of a classification error. For a training set sifiers at level 1. One can see from Table 2 that the KNN
X with N number of training examples, if {(x i, di)} is the ith with Euclidean distance metric and 4 neighbors produces
732 R. Rajagopal, V. Ranganathan. A model for cardiac arrhythmia classification
Table 2. Average classification results of tenfold cross validation Table 5. Sensitivity and F-score of class S before and after using
for classifiers at level 1 the proposed model
Sensitivity of class S F-Score of class S
Average accuracy
Fold
Average positive
Average F-score
number
predictivity
KNN – EUC 4 Proposed KNN – EUC 4 Proposed
specificity
sensitivity
Average
Average
Classifier Fold 1 88.68 90.56 92.16 92.30
Fold 2 88.30 91.32 91.40 93.07
Fold 3 85.28 87.54 90.58 90.62
KNN-Euclidean 4 92.14 99.24 98.56 94.48 99.77 Fold 4 88.67 91.69 92.33 92.74
KNN-Euclidean 3 92.07 99.23 98.53 94.43 99.76 Fold 5 88.67 90.56 91.79 92.13
KNN-correlation 84.53 99.07 97.92 87.16 99.71 Fold 6 85.66 88.30 89.90 90.00
KNN-Mahalanobis 91.05 99.21 94.74 92.39 99.72 Fold 7 92.07 93.58 94.02 93.23
KNN-standardized Euclidean 91.11 99.22 94.97 92.53 99.73 Fold 8 89.43 90.56 92.75 92.13
KNN-Spearman 84.45 98.19 89.09 85.23 99.30 Fold 9 90.18 91.69 93.35 92.57
Tree classifier 77.80 98.15 83.72 78.98 99.28 Fold 10 92.07 94.33 93.84 93.80
Discriminant-linear 72.42 93.20 60.87 61.41 98.28
KNN-EUC 4 – K-nearest neighbour classifier with Euclidean distance 4.
Discriminant-quadratic 72.56 97.27 92.68 74.97 99.06
References 25. Oresko JJ, Jin Z, Huang S, Sun Y, Duschl, Cheng AC . A wearable smart
phone based platform for real time cardiovascular disease detec-
1. Mehra R. Global public health problem of sudden cardiac death.
tion via electrocardiogram processing. IEEE Trans Inf Technol Biomed.
J Electrocardiol. 2007; 40(6 Suppl):118–122.
2010;3(14):734–740.
2. Kim J, Shin HS, K, Shin, Lee M. Robust algorithm for arrhythmia clas-
26. Wiens J, Guttag JV. Patient adaptive ectopic beat classification using
sification in ECG using extreme learning machine. Bio Medical Engi-
active learning. Comput Cardiol. 2010;37:109–112.
neering Online. 2009. https://doi.org/10.1186/1475-925X-8-31
27. Li D, Pedrycz W, Pizzi JN. Fuzzy wavelet packet based feature extrac-
3. Liang W, Zhang Y, Tan J, Li Y. A novel approach to ECG classification
tion method and its application to biomedical signal classification.
based upon two-layered HMMs in body sensor networks. Sensors.
IEEE Trans Biomed Eng. 2005;6(52):1132–1139.
2014;14(4):5994–6011.
28. Luz E, Menotti D. How the choice of samples for building arrhyth-
4. Kim H, Yazicioglu RF, Merken P, Van Hoof C, Yoo HJ. ECG signal com-
mia classifiers impact their performances. Proc Conf IEEE Eng Med
pression and classification algorithm with quad level vector for ECG
Biol Soc. 2011;4988–4991.
holter system. IEEE Trans Inf Technol Biomed. 2010;14(1):93–100.
5. Asl BM, Setarehdan SK, Mohebbi M. Support vector machine – based
arrhythmia classification using reduced features of heart rate vari-
ability signal. Artif Intell Med. 2008;1(44):51–64.
6. Huang K, Zhang L. Cardiology knowledge free ECG feature extraction
using generalized tensor rank one discriminant analysis. EURASIP J
Appl Signal Processing. 2014. https://doi.org/10.1186/1687-6180-2014-2
7. Zhu B, Ding Y, Hao K. A novel automatic detection for ECG arrhyth-
mias using maximum margin clustering with immune evolution-
ary algorithm. Comput Math Methods Med. 2013. http://dx.doi.
org/10.1155/2013/453402
8. Chazal P, Dwyer MO, Reilly RB. Automatic classification of heartbeats
using ECG morphology and heartbeat interval features. IEEE Trans
Biomed Eng. 2004;7(51):1196-1206.
9. Roshan Joy Martis, Rajendra Acharya U, Lim Choo Min. ECG beat
classification using PCA, LDA, ICA and discrete wavelet transform.
Biomed Signal Process Control. 2013;5(8):437–448.
10. Manab Kumar Das, Samit Ari. ECG beats classification using
mixture of features. Int Sch Res Notices. 2014;2014:178436. doi:
10.1155/2014/178436
11. Das MK, Ari S. Electrocardiogram beat classification using S-Trans-
form based feature set. J Mech Med Biol. 2014;5(14):1450066.
12. Rai HM, Trivedi A, Shukla S. ECG signal processing for abnormali-
ties detection using multi-resolution wavelet transform and artifi-
cial neural network classifier. Measurement. 2013;9(46):3238–3246.
13. Song MH, Lee J, Lee KJ, Yoo SK. Support vector machine based
arrhythmia classification using reduced features. Int J Control Autom.
2005;4(3):571–579.
14. Zidelmal Z, Amirou A, Ould Abdeslam D, Merckle J. ECG beat clas-
sification using a cost sensitive classifier. Comput Meth Prog Bio.
2013;3(111):570–577.
15. Daamouche A, Hamami L, Alajlan N, Melgani F. A wavelet optimi-
zation approach for ECG signal classification. Biomed Signal Process
Control. 2012;(7):342 –349.
16. Ubeyli ED. Usage of Eigen vector methods in implementation
of automated diagnostic systems for ECG beats. Digit Signal Pro-
cess. 2008;33(18):33–48.
17. Moody GB, Mark RG. The impact of the MIT_BIH arrhythmia data-
base. IEEE Eng Med Biol. 2001;3(20):45–50.
18. Singh BN, Tiwari AK. Optimal selection of wavelet basis function
applied to ECG signal denoising. Digit Signal Process. 2006;3(16):
275–287.
19. Pan J, Tompkins JW. A real time QRS detection algorithm. IEEE Trans
Biomed Eng. 1985;3(32). https://doi.org/10.1109/TBME.1985.325532
20. Kim J, Kim BS, Savarese S. Comparing image classification meth-
ods: K Nearest Neighbor and Support Vector Machines. Applied
Mathematics in Electrical and Computer Engineering. 2012;
133–138.
21. Ghoraani B, Krishnan S. Discriminant non-stationary signal features
clustering using hard and fuzzy cluster labeling. EURASIP J Adv Signal
Process. 2012. https://doi.org/10.1186/1687-6180-2012-250
22. Mazomenos EB, Biswas D, Acharyya A, et al. A low-complexity ECG
feature extraction algorithm for mobile healthcare applications. IEEE
J Biomed Health Inform. 2013;2(17):459–569.
23. Sufi F, Khalil I,Mahmood AN. A clustering based system for instant
detection of cardiac abnormalities from compressed ECG. Expert Syst
Appl. 2011;5(38):4705–4713.
24. Melgani F, Bazi Y. Classification of electrocardiogram signals with
support vector machines and particle swarm optimization. IEEE Trans
Inf Technol Biomed. 2008;5(12):667–677.