ECG Classification Performing Feature Extraction Automatically Using a Hybrid CNN-SVM Algorithm
ECG Classification Performing Feature Extraction Automatically Using a Hybrid CNN-SVM Algorithm
2021 3rd International Congress on Human-Computer Interaction, Optimization and Robotic Applications (HORA) | 978-1-6654-4058-5/20/$31.00 ©2021 IEEE | DOI: 10.1109/HORA52670.2021.9461295
Abstract— In this study, we have presented a hybrid ECG signals. Diker et al. [3], in their study, used Differential
Convolution Neural Network (CNN)-Support Vector Evolution Algorithm (DEA) for Physikalisch-Technische
Machine (SVM) algorithm which has overcome overfitting Bundesanstalt (PTB) Diagnostic ECG classification. Moreover,
for classifying Electrocardiogram (ECG) signals that have they used to optimize the number of hidden neurons of extreme
been transformed to 2D images using continuous wavelet learning machine (ELM) for DEA. Thus, they achieved a 97.5%
transform (CWT). We also have suggested ProposedNet accuracy rate with the DEA-ELM hybrid algorithm. Hasan and
that is a kind of convolutional neural network algorithm. Bhattacharjee [4] used a convolution neural network (CNN) to
Also, it has been trained more than once. Moreover, it has classify ECG databases. They achieved a 97.70% accuracy rate
performed feature extraction automatically. We have for the MIT-BIH database, a 99.71% accuracy rate for the St-
compared the ProposedNet which has 34 layers, with SVM. Petersburg database, a 98.24 % accuracy rate for the PTB
Additionally, we also have compared ProposedNet-SVM database with their proposed method. Of course, not only these
that is also our suggestion, with these algorithms. researchers have studied but also Sun et al.[5], Remya et al.[6],
Comparison results indicate that ProposedNet, SVM, and Hammad et al. [7], Banerjee and Mitra[8], Padhy and Dandapat
ProposedNet-SVM have been achieved accuracy rates of [9], and Sahoo et al. [10] have made various classification
95.6%, 89.17%, and 99.524% respectively. studies on the ECG dataset, especially on the PTB dataset.
In this study, we have aimed to take advantage of the deep
Keywords—CNN, Electrocardiogram (ECG), Support Vector learning technique, which has been very popular in recent
Machine (SVM), overfitting, 2D images years. CNN, which is very effective in image processing, gives
I. INTRODUCTION very good results in multidimensional data. Moreover, thanks
to its end-to-end structure, it successfully performs feature
extraction. With the proposed CNN algorithm, called as
Most deaths are due to heart attacks worldwide. With ProposedNet which has 34 layers, we classified the ECG data
Covid 19, the importance of heart health has increased. These with high accuracy. However, since we have aimed to perform
days, where the experts' burden is quite high, it has been first the classification almost error-free, we suggested the CNN-
the goal of us researchers to develop time-saving and accurate SVM hybrid algorithm, called ProposedNet-SVM which is a
classification algorithms. Electrocardiogram (ECG) is one of more efficient feature extraction algorithm and overcome
the recording electrical activities of the heart by utilizing extreme learning. Thus, we have achieved a much higher
electrodes[1]. ECG records are converted into digits which are accuracy rate with this hybrid algorithm we proposed.
used for analysis. Classification and analysis of ECG signals
are very important in understanding what heart disease is. For II. DATASET
this purpose, many researchers have studied the classification In this study, we have used Physikalisch-Technische
of ECG signals. Huang et al. [2], in their study, classified ECG Bundesanstalt (PTB) Diagnostic ECG Database[11-13]. The
signals using both 1D-CNN and 2D-CNN algorithms. They database includes 148 diagnostics of myocardial infarction
first transformed spectrograms using a short-time Fourier called an abnormal class and 52 diagnostics of health controls
transform. When they classified with the 2D-CNN algorithm, it called a normal class. Although every record includes the signal
was achieved a 99% accuracy rate. Besides, when they also from 12 leads, we have examined lead II. The dataset contains
classified with the 1D-CNN algorithm, it was achieved a 14552 samples and 2 classes. In this study, we have transformed
90.33% accuracy rate. They emphasized that the 2D-CNN one-dimensional signals into two-dimensional images using
classifier was more efficient than the 1D-CNN classifier on continuous wavelet transform (CWT) which was created with
sampling of 500 Hz and “Amor” mother wavelet function. In
Authorized licensed use limited to: ULAKBIM UASL - Hacettepe Universitesi. Downloaded on September 15,2021 at 10:36:20 UTC from IEEE Xplore. Restrictions apply.
this condition, we have comprised 600 images (or scalograms)
taken in equal numbers from each class that supplied from ECG
signals randomly. Hence, we have prepared scalograms for the
classification phase, detailed in Fig. 1.
Authorized licensed use limited to: ULAKBIM UASL - Hacettepe Universitesi. Downloaded on September 15,2021 at 10:36:20 UTC from IEEE Xplore. Restrictions apply.
the excellent generalization capability of the learning machine TABLE I. PROPOSEDNET DETAILS.
[18].
SVM is also flexible and in accordance with other Layer Name Number of Filters Output Size Stride Activation
algorithms, especially for feature extraction. Thus, we have Input - 227x227x3 - -
merged with CNN and SVM algorithms because of these Conv-1 5x5 225x225x64 1 ReLU
properties. MaxPool-1 3x3 112x112x64 2
Conv-2 3x3 112x112x128 1 ReLU
MaxPool-2 3x3 55x55x128 2
D. Performance Metrics Conv-3 13x13 55x55x128 1 ReLU
MaxPool-3 3x3 27x27x128 2
When the ProposedNet, SVM, and ProposedNet-SVM are Conv-4 7x7 27x27x256 1 ReLU
wanted to measure in terms of classification success, should be MaxPool-4 2x2 13x13x256 2
calculated performance metrics such as accuracy rate, Conv-5 3x3 13x13x128 1 ReLU
sensitivity, specificity, and F1-score which are depended on MaxPool-5 3x3 6x6x128 2
True Positive(TP), False Positive (FP), True Negative (TN), Conv-6 3x3 6x6x128 1 ReLU
and False Negative (FN), given in Equation (2-5). MaxPool-6 3x3 3x3x128 2
In recent studies, it has been stated that the accuracy rate Conv-7 3x3 3x3x128 1 ReLU
alone is not sufficient. Thus, the confusion matrix should be MaxPool-7 2x2 1x1x128 2
also examined for classification success [19]. FC-8 1 1x1x4096 -
Drop-8 50% -
TP + TN FC-9
3 (number of
1x1x3 -
Accuracy = (2) class)
TP + TN + FP + FN Softmax 1x1x3 -
TP Output Cross entropy -
Sensitivity = (3)
TP + FN
TN The ProposedNet has not been trained just once. Because of
Specificity = (4)
TN + FP seeing if it succeeds It has been trained and recorded 5 times in
2 × Pr ecision × Sensitivity a cycle too, detailed in Table II. As a result of our investigation,
F1 − Score = (5) the average success of ProposedNet in terms of all performance
Pr ecision + Sensitivity metrics which is over 94.95 % is too high and its standard
deviation is too low. Despite all these successful results, we have
thought that the classification success of signals received from
IV. RESULTS an important organ such as the heart should be much higher.
Therefore, we have tried that combine with SVM to
Most deaths are due to heart attacks. That's why heart health ProposedNet.
is very important. In this study, we aimed to reduce the workload TABLE II. PROPOSEDNET AVERAGE PERFORMANCE METRİCS
of experts working in this field. Hence, with our proposed CNN
structure, the signals received from the heart will be classified Performance Metrics
Training
easily and with high reliability. Firstly, we have taken data that Number F1-
Sensitivity(%) Specificity(%) Accuracy(%)
Score(%)
is processed from Kaggle [11]. And then, we have transformed
1 96.0784 97.9592 97.03 97
1D data to 2D image data providing by CWT which is
implemented the “Amor” wavelet function to a 500 Hz sampling 2 92.3077 95.8333 94.12 94
length. The reason for using the “Amor” wavelet function and 3 97.8723 92.4528 94.85 95
500 Hz signal length is that we have obtained the best results
with these properties in the previously unpublished study. 4 97.8723 92.4528 94.85 95
Secondly, we have allocated 80% for training and 20% for 5 97.9592 96.0784 96.97 97
testing of the 600 images we have created. Thus, we have Mean+Std 96.418±2.43 94.9553±2.428 95.56±1.35 95.6±1.3416
prepared images of size as 227x227x3 and .jpg format for
ProposedNet input.
SVM is one of the best algorithms that provide feature
extraction easily. Thanks to its flexible structure, it can easily
adapt to CNN architectures. In this study, we have deemed it
appropriate to remove the fully connected (FC-8) layer of the
architecture we have proposed and to replace it with SVM. As
consequently, the combination of SVM and ProposedNet has
had a positive impact on the result, detailed in Table III.
Authorized licensed use limited to: ULAKBIM UASL - Hacettepe Universitesi. Downloaded on September 15,2021 at 10:36:20 UTC from IEEE Xplore. Restrictions apply.
TABLE III. PROPOSEDNET-SVM PERFORMANCE METRICS
Performance Metrics
Removed
Layer Sensitivity(%) Specificity(%) F1-Score(%) Accuracy(%)
Performance Metrics
Algorithm F1-
Sensitivity(%) Specificity(%) Accuracy(%)
Score(%)
ProposedNet 96.418 94.9553 95.53 95.6
SVM 95 83.33 89.76 89.17
TABLE V. COMPARISON OF SOME STUDIES ON PTB DATASET
ProposedNet- CLASSIFICATION
99.5238 99.5238 99.52 99.524
SVM
Study Accuracy(%)
V. CONCLUSION
Authorized licensed use limited to: ULAKBIM UASL - Hacettepe Universitesi. Downloaded on September 15,2021 at 10:36:20 UTC from IEEE Xplore. Restrictions apply.
REFERENCES [12] A. L. Goldberger et al., "PhysioBank, PhysioToolkit, and
PhysioNet: components of a new research resource for complex
physiologic signals," circulation, vol. 101, no. 23, pp. e215-e220,
[1] R. R. Al-Yami, T. N. Alotaiby, L. M. Aljafar, S. A. Alshebeili, and 2000.
J. Zouhair, "Classification of single-lead ECG signal to normal and [13] R. Bousseljot, D. Kreiseler, and A. Schnabel, "Nutzung der EKG-
abnormal subjects using histogram-based features," in 2017 Signaldatenbank CARDIODAT der PTB über das Internet,"
International Conference on Electrical and Computing Biomedical Engineering/Biomedizinische Technik, vol. 40, no. s1,
Technologies and Applications (ICECTA), 2017: IEEE, pp. 1-3. pp. 317-318, 1995.
[2] J. Huang, B. Chen, B. Yao, and W. He, "ECG arrhythmia [14] D. L. Fugal, Conceptual wavelets in digital signal processing: an
classification using STFT-based spectrogram and convolutional in-depth, practical approach for the non-mathematician. Space &
neural network," IEEE Access, vol. 7, pp. 92871-92880, 2019. Signals Technical Pub., 2009.
[3] A. Diker, E. Avci, E. Tanyildizi, and M. Gedikpinar, "A novel ECG [15] H. K. Lee and Y.-S. Choi, "Application of continuous wavelet
signal classification method using DEA-ELM," Medical transform and convolutional neural network in decoding motor
hypotheses, vol. 136, p. 109515, 2020. imagery brain-computer interface," Entropy, vol. 21, no. 12, p.
[4] N. I. Hasan and A. Bhattacharjee, "Deep learning approach to 1199, 2019.
cardiovascular disease classification employing modified ECG [16] M. Elleuch, R. Maalej, and M. Kherallah, "A new design based-
signal from empirical mode decomposition," Biomedical Signal SVM of the CNN classifier architecture with dropout for offline
Processing and Control, vol. 52, pp. 128-140, 2019. Arabic handwritten recognition," Procedia Computer Science, vol.
[5] L. Sun, Y. Lu, K. Yang, and S. Li, "ECG analysis using multiple 80, pp. 1712-1723, 2016.
instance learning for myocardial infarction detection," IEEE [17] U. B. Baloglu, M. Talo, O. Yildirim, R. San Tan, and U. R. Acharya,
transactions on biomedical engineering, vol. 59, no. 12, pp. 3348- "Classification of myocardial infarction with multi-lead ECG
3356, 2012. signals and deep CNN," Pattern Recognition Letters, vol. 122, pp.
[6] R. Remya, K. Indiradevi, and K. A. Babu, "Classification of 23-30, 2019.
myocardial infarction using multi resolution wavelet analysis of [18] C. Cortes and V. Vapnik, "Support-vector networks," Machine
ECG," Procedia Technology, vol. 24, pp. 949-956, 2016. learning, vol. 20, no. 3, pp. 273-297, 1995.
[7] M. Hammad, G. Luo, and K. Wang, "Cancelable biometric [19] M. Koklu and I. A. Ozkan, "Multiclass classification of dry beans
authentication system based on ECG," Multimedia Tools and using computer vision and machine learning techniques,"
Applications, vol. 78, no. 2, pp. 1857-1887, 2019. Computers and Electronics in Agriculture, vol. 174, p. 105507,
[8] S. Banerjee and M. Mitra, "Application of cross wavelet transform 2020.
for ECG pattern analysis and classification," IEEE transactions on [20] U. R. Acharya, H. Fujita, S. L. Oh, Y. Hagiwara, J. H. Tan, and M.
instrumentation and measurement, vol. 63, no. 2, pp. 326-333, Adam, "Application of deep convolutional neural network for
2013. automated detection of myocardial infarction using ECG signals,"
[9] S. Padhy and S. Dandapat, "Third-order tensor based analysis of Information Sciences, vol. 415, pp. 190-198, 2017.
multilead ECG for classification of myocardial infarction," [21] M. Kachuee, S. Fazeli, and M. Sarrafzadeh, "Ecg heartbeat
Biomedical Signal Processing and Control, vol. 31, pp. 71-78, classification: A deep transferable representation," in 2018 IEEE
2017. International Conference on Healthcare Informatics (ICHI), 2018:
[10] S. Sahoo, B. Kanungo, S. Behera, and S. Sabut, "Multiresolution IEEE, pp. 443-444.
wavelet transform based feature extraction and ECG classification [22] S. A. A. Yusuf and R. Hidayat, "MFCC feature extraction and KNN
to detect cardiac abnormalities," Measurement, vol. 108, pp. 55-66, classification in ECG signals," in 2019 6th International Conference
2017. on Information Technology, Computer and Electrical Engineering
[11] S. Fazeli. "Kaggle." (ICITACEE), 2019: IEEE, pp. 1-5.
https://www.kaggle.com/shayanfazeli/heartbeat (accessed
05.04.2021 14:36.
Authorized licensed use limited to: ULAKBIM UASL - Hacettepe Universitesi. Downloaded on September 15,2021 at 10:36:20 UTC from IEEE Xplore. Restrictions apply.