(Journal Q2 2023) Heart Arrhythmia Detection and Classification A Comparative Study

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

https://doi.org/10.1007/s40998-023-00633-6 (0123456789().,-volV)(0123456789().
,- volV)

RESEARCH PAPER

Heart Arrhythmia Detection and Classification: A Comparative Study


Using Deep Learning Models
Anuja Arora1 • Anu Taneja2 • Jude Hemanth3

Received: 7 July 2022 / Accepted: 19 June 2023 / Published online: 7 July 2023
Ó The Author(s), under exclusive licence to Shiraz University 2023

Abstract
The irregular functioning of heartbeats known as ‘‘Heart Arrhythmia’’ may lead to heart palpitations, blood clots, and even
a heart stroke. The ECG test is one of the primary clinical tests that are utilized to detect heart abnormalities due to its
noninvasive nature. However, this method is an extremely time-consuming process due to variations in ECG signals. The
main aim of this study is to automate this manual process as computer-aided detection can diagnose with more precision
and accuracy. This research study is a comparative study that detects and classifies arrhythmia using various deep learning
models that is a one-dimensional convolutional neural network, two-dimensional convolutional neural network (2D-CNN),
2D-CNN with long short-term memory network, and in addition to this, models are combined using ensemble learning to
develop a classifier. These classifiers help discriminate signs of arrhythmia disease. The idea is implemented on ECG
Heartbeat Categorization data, derived from the MIT-BIH arrhythmia dataset. The utilization of deep learning-based
methods helps to achieve promising results and show significant improvements as compared to baseline methods. This
study would benefit the medical experts in early arrhythmia diagnosis as faster detection can save more human lives.

Keywords Arrhythmia classification  Bagging  Convolutional neural network  Deep learning  ECG signals 
Long short-term memory network

1 Introduction atrium (two upper chambers) and ventricles (two lower


chambers). The flow of blood is restrained through syn-
Heart-related problems are one of the prevalent reasons chronized cycles of expansions and contractions of these
behind the increased mortality rate as early and precise four chambers. The slight delay in the expansions or con-
diagnosis of heart diseases is a major challenge. The heart tractions of the heart chambers can prove to be fatal for the
plays an important role in the circulation of blood human body. Heart Arrhythmia is also one of the heart
throughout the body, and it consists of four chambers: diseases that arise due to irregularities in the heartbeats
caused by the altered rate of expansions or contractions of
one or more of these heart chambers (Luz et al. 2016).
& Jude Hemanth There are distinct types of arrhythmias like atrial fibrilla-
judehemanth@karunya.edu
tion: it occurs, in case, atrial chambers beat rapidly; atrial
Anuja Arora flutter: it arises due to abnormal working from one of the
anuja.arora@jiit.ac.in
areas in the atrium; ventricle fibrillation: irregular heart
Anu Taneja rhythm occurs due to uncoordinated contractions of ven-
anutaneja16@gmail.com
tricles and many more (Jambukia et al. 2015). However, if
1
Department of Computer Science and Information an arrhythmia is not diagnosed timely or treated well, it can
Technology, Jaypee Institute of Information Technology, even result in heart failure.
Noida, Uttar Pradesh, India The electrocardiogram (ECG) is one of the popular and
2
Department of Computer Science, BCIIT, GGSIPU, Kalkaji, reliable medical tests that is accomplished by medical
Delhi, India experts to detect arrhythmia: irregularities in heartbeats,
3
Department of ECE, Karunya Institute of Technology and diagnose other cardiac-related diseases and monitor the
Sciences, Coimbatore, India

123
1636 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

overall functionality of the heart. This test measures the like manual pre-processing of signals is required, these
electrical activity of heartbeat (Karpagachelvi et al. 2010). techniques are expensive and time-consuming.
In this process, electrodes are placed on the human’s chest In recent years, to overcome the above-mentioned
and limbs that measure the rhythm of the heartbeats and problems, researchers applied deep learning models like
display it like waves on the monitor. The upper chambers Convolutional Neural Network (CNN), Recurrent Neural
of the heart form the wave known as ‘P-wave’ that follows Network (RNN) to study the ECG signal but still, the work
the flat line when electrical impulses move to the bottom accomplished using these models rely on pre-processing of
chambers, the ventricles form the QRS complex wave, and the signals and this might lead to loss of information
then, final T-wave is formed that depicts the electrical (Acharya et al. 2017; Hannun et al. 2019) from the ECG
recovery or return to the resting state of the ventricles. signal. The authors have applied one-dimensional convo-
However, the analysis of ECG signal is itself a complex lutional neural networks to classify the signals into
task due to variation in beats; small amplitude; difficulty in appropriate normal or arrhythmic classes, and then, the
accurately recognizing ECG components. Thus, doctors authors combined two 1D-CNN to automatically detect the
may prescribe additional tests such as chest X-ray, elec- QRS waves from the ECG signals (Xu and Liu 2020; Zhai
trophysiologic testing, Holter monitor, and a variety of and Tin 2018). Thereafter, to avoid the loss of information
other invasive and noninvasive tests (Hagiwara et al. 2018) from the signals, two-dimensional CNN has been applied
based on an ECG test to continuously monitor the heart for by various authors for arrhythmia detection and classifi-
few days to diagnose arrhythmia. Further, the study of cation (Jun et al. 2018; Salem et al. 2018). Further,
ECG reports requires human experts that can lead to recurrent neural network variants are used for the analysis
manual errors. The multiple opinions of doctors can also of time-series ECG signals as these networks can retain the
even lead to misdiagnosis of arrhythmia detection. To past as well as current information. The authors combined
overcome these issues, an intelligent system is required that convolutional neural networks and long short-term memory
can automate the task of arrhythmia detection, reduces the networks (LSTM) to early diagnose arrhythmia (Gao et al.
probability of errors, and makes the system more reliable 2019; Picon et al. 2019; Yildirim 2018). It has been
due to automation. Thus, in this research study, an intel- observed that the evolution of deep learning into this
ligent system is developed using deep-learning-based domain has made a significant contribution to arrhythmia
models that is one-dimensional Convolutional Neural classification.
Network (1D-CNN) (Cui et al. 2021), two-dimensional Inspired by these ideas, this research study conducts a
Convolution Neural Network (2D-CNN), CNN with long thorough comparison of the multiple deep learning-based
short-term memory network (LSTM), and an ensemble models that are then integrated using ensemble learning to
model to automate the task of arrhythmia detection and build a strong classifier. The models can detect and classify
classification that significantly reduces the time, efforts and arrhythmia that makes it more efficient over baseline
increases the accuracy of the task to a large extent. methods. To the best of our knowledge, this study is a
The early detection of arrhythmia and save more human novel effort to provide a detailed comparative study of
lives is a challenging task, and hence, it is still an active different deep-learning-based classifiers.
area of research for further improvements in the existing The key contributions of this research study are as
approaches. Though various solutions exist in the literature follows:
for arrhythmia detection, earlier studies intensively worked
1. Developed an intelligent system that can detect
on filtering noise from ECG signals (Agante and Sá 1999;
arrhythmia in the early stages.
Poungponsri and Yu 2013; Sameni et al. 2005). Thereafter,
2. Utilized deep learning models for arrhythmia detection
various models are proposed (Hu et al. 1997; Sayadi and
and classification problem to further optimize the
Shamsollahi 2009) based on signal segmentation, manual
performance of existing methods.
feature extraction (Vijaya et al. 2011; Ye et al. 2012),
3. Performed comparative study to assess the perfor-
Support Vector Machines (SVM), and their variants like
mance of different classifiers.
Relevance Vector Machines (RVM) (Gayathri et al. 2012;
4. Provides deep insight into this domain and eases the
Osowski et al. 2004). Further, researchers performed fea-
task of medical professionals to study the ECG signals
ture engineering to extract more features of ECG signal
with more accuracy.
such as area and amplitude of the waves. The researchers
proposed various machine learning-based methods and Under the Association for the Advancement of Medical
utilized higher-order statistics and Hermite functions to Instrumentation (AAMI), the following five categories of
extract more features (Chazal et al. 2004; Osowski et al. arrhythmia signals: Normal Beats (N), Supraventricular
2004). Though traditional methods have their limitations Ectopic Beat (S), Ventricular ectopic beats (V), Fusion
beats (F), Unknown beats (Q), are not life-threatening

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1637

(Association for the Advancement of Medical Instrumen- and low-frequency noises while cleaning the ECG signal
tation 1998); thus, in this study, various deep-learning- data. Though many of these methods have achieved high
based classifiers are developed to categorize these types of accuracy but are dependent on manual extraction of fea-
heartbeats. The main objective of this study is to help tures that increases the computational complexity of the
medical professionals in the early diagnosis of arrhythmia methods.
and classification too. It automates the task of detection The researchers have also proposed various novel
with more accuracy. The proposed research study does not methods for noise reduction from ECG signals based on
depend on signal pre-processing and feature reduction adaptive filters (Poungponsri and Yu 2013, Rakshit and das
techniques to extract the relevant information from the 2018, and Ziarani and Konrad 2002), wavelet transforms
ECG signals; thus, it is computationally less intensive. This (Agante and De Sá 1999, Vijaya et al. 2011, and Li et al.
study would serve as a support for medical professionals as 2017), nonlinear Bayesian filters (Sayadi and Shamsollahi
this study automates the task of arrhythmia detection and 2009), Kalman filters (Yildirim 2018). For instance, Rak-
classification and reduces the efforts as well as the pre- shit et al. proposed a better denoising method based on
processing time of the signals. This initiative aims to empirical mode decomposition (EMD) and an adaptive
combat heart arrhythmia-related problems and save more switching mean filter (ASMF). According to the results of
human lives. The novelty of the paper is to enrich the the study, the proposed method may be utilized to effec-
medical experts’ experience and classify as well as to tively reduce the noise in ECG signals (Rakshit and Das
detect arrhythmia patients simultaneously. 2018). But, before trying any complex filtering algorithm
The remaining paper is organized as follows: Sect. 2 in pre-processing phase, it is important to understand what
details the related work in this domain that covers literature features need to be recognized. ECG signal for arrhythmia
related to pre-processing and learning models; Sect. 3 signal is clearly a time-series problem, and a clear ECG
presents the comprehensive overview of the five deep signal is depicted in Fig. 1. The main problem of ECG
learning models and their architectures used in the study signal is that the quality of signal might change with time,
for heart arrhythmia detection. The performance evaluation i.e., (1) Reflects high quality during low activity in which
and corresponding outcome of all the models are discussed P, QRS, and T ware are detectable such as Heart Attack (2)
in Sect. 4 in detail. The discussion relevant to recent work poor quality during intense moving such as cardiac exer-
in particular is detailed in Sect. 5, and finally, concluding cise only some abnormalities in QRS is noticeable. To
remark and future scope is outlined in Sect. 6. overcome this problem, researchers applied the Min–Max
principle of game theory (Dai et al. 2021). Another well-
known and powerful signal detection process is the adap-
2 Related Work tive filter that changes impulse response to the changing
environment. The Independent component analysis
2.1 Literature Studied Relevant to ECG Signal (Ramkumar et al. 2021) and Blind Source Separation
Pre-processing (Sadiq et al. 2021) are the most popular process for

A study on data pre-processing techniques used in state-of-


the-art models is detailed in this section for readers’
viewpoint. ECG signals provide the most accurate real-
time electrical activity to give information about the
structure and functionality of the heart. During transmis-
sion and acquisition of ECG signals using ECG monitoring
system, different noises could be introduced. The noises
are mainly of two kinds—high-frequency noise and low-
frequency noise. The high-frequency noise consists of
power line noise, white Gaussian noise, motion noise
(electromyogram), and low-frequency noise consists of
baseline drifts, and electrode contact loss. The traditional
denoising approaches are either for the high frequency or
low frequency. Nowadays, despite separate denoising
techniques, the filters are used to remove undesired signal
components as both high frequency and low frequency
displays overlapping spectrum. The IIR Notch and FIR Fig. 1 ECG of a heart, waves: P, QRS, and T, intervals: PR and QT
filters both were traditionally used to eliminate both high- (Ashley and Niebauer 2004)

123
1638 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

multichannel configuration, but these are not suitable for enhance the classification accuracy and the proposed
real-time due to the usage of more computational approach is also highly dependent on pre-processing and
resources. feature extraction techniques. In 2018, authors used
wrapper-based feature selection techniques to reduce the
2.2 Literature Studied Relevant to Machine dimensions and utilized SVM-based approaches that are
Learning and Deep Learning Models one-against-one, one-against-all, and error correction code
to detect the presence of an arrhythmia. The results validate
This section discusses the relevant work related to this that the one-against-one method of the SVM approach
domain such as various approaches have been proposed for achieves the highest accuracy (Mustaqeem et al. 2018).
detection and classification like Support Vector Machines Similarly, in 2018, authors introduced Optimum-Path
(SVM), Relevance Vector Machines (RVM), Genetic Forest, an SVM-based classifier that was evaluated on
Algorithms, Bayesian method (Khatibi and Rabinezhad- several distance metrics and compared to other classifiers
sadatmahaleh 2020; Li et al. 2017; Nasiri et al. 2009). For too (Albuquerque et al. 2018). Moreover, in addition to
instance, the researchers in their work utilized three arrhythmia detection and classification, researchers have
Bayesian classifiers that are Naı̈ve Bayes, linear discrimi- also worked in the direction of proposing novel feature
nant analysis (LDA), and quadratic discriminant analysis engineering methods. Khatibi et al. (2020) in their work
(QDA) to classify the ECG beats into relevant classes. have used deep learning and KNN to extract the features,
According to the results, the QDA classifier is the best of and then, these features are classified with various classi-
the three classifiers (Casas et al. 2018). Further, the authors fiers such as SVM with different kernels, decision trees,
in their work (Osowski et al. 2004) developed an expert and random forests. Furthermore, Yang et al. (2018) and
system for heartbeat recognition using Support Vector fellow authors suggested a unique classification strategy
Machine (SVM) on MIT-BIH arrhythmia dataset that is with stacked sparse auto-encoders and a soft regression
dependent on two pre-processing methods that involve model to extract the features automatically and improve the
higher-order statistics and Hermite characterization of QRS model’s robustness. Their findings substantiate the models’
wave of ECG signal and a final classifier is generated by usefulness.
combining using weighted voting principle. It is observed In the later years, machine learning and other deep
that a combined classifier gives better results than indi- learning-based models have evolved into this domain that
vidual classifiers. The authors in their work (Tsipouras and automates the task of detection and classification, but these
Fotiadis 2004) detect arrhythmia based on the time and models have their own limitations like dependency on
frequency features, and these features are used to train the signal pre-processing techniques to process the ECG sig-
neural networks. The R-R interval duration signal is nal. Thus, these models are computationally expensive and
extracted from the ECG recordings, and decision rules are time-consuming as the process must be carried out manu-
applied to combine the outputs of all neural networks and ally with the help of experts. Javed et al. (2010) in their
achieved good results. In addition, the authors devised a work proposed an artificial neural network (ANN)-based
low-cost approach based on a linear regression algorithm to system that is Multi-Layer Perceptron with an error prop-
identify various ECG signal peaks (Aspuru et al. 2019) and agation algorithm for arrhythmia classification and
validated the model’s durability by creating an ECG sensor achieves a classification accuracy of 86.67%. Another work
to register and transmit the data to a mobile device. In using an artificial neural network is explored by Mitra et al.
2009, researchers proposed a method that combines SVM (2013) in which authors have used correlation-based fea-
and Genetic Algorithms and extracted 22 features from ture selection with a linear feed-forward neural network
time voltage of R, S, T, P, Q features of ECG signals and and have achieved an accuracy of 87.71%. Further, in
obtain classification accuracy of 93.46% (Nasiri et al. 2013, researchers proposed a probabilistic neural network
2009). The researchers in their work (Polat and Güneş classifier that initially applied a feature reduction method
2007) uses least square support vector machine along with combining principal component analysis (PCA) with linear
principal component analysis and yield accuracy of about discriminant analysis (LDA) and achieved satisfactory
96%. accuracy. In 2017, the authors proposed a novel genetic
Further, authors in their work (Gayathri et al. 2012) algorithm-based back propagation neural network and used
applied the Relevance Vector Machine (RVM) model, a the wavelet packet decomposition method to extract the
variant of the Support Vector Machine (SVM) to accu- relevant features. The findings show that the proposed
rately classify the ECG beats on the MIT-BIH arrhythmia method has a high level of classification accuracy (Li et al.
database. The results signify that this model outperforms 2017). Later in 2018, authors utilized multilayer perceptron
the traditional classifiers. But authors ascertain to use of (MLP) and Convolutional Neural Network (CNN)-based
some advanced techniques to train the RVM classifier to algorithms and were able to diagnose the diseases in all

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1639

states with high accuracy (Savalia and Emamian 2018). on a 1D-convolutional network and long short-term
Recently, in 2019, researchers proposed architecture based memory network for the detection of ventricular fibrillation
on a deep convolutional neural network (CNN) that is not and achieved promising results. Hou et al. (2019) proposed
dependent on pre-processing techniques like feature a novel method that combines LSTM and SVM for
extraction and feature reduction and still achieves arrhythmia classification. A novel three-layer-based deep
promising results (Sellami and Hwang 2019). Similarly, the genetic ensemble of classifiers (DGEC) is introduced that
authors (Rajkumar et al. 2019) applied a convolutional integrates ensemble learning, deep learning, and evolu-
neural network to categorize the heartbeats into appropriate tionary computation, and the experiments show that the
classes and achieve an accuracy of about 93%. In 2020, suggested methodology obtains promising results (Pławiak
researchers in their work adopted coupled convolutional and Acharya 2020). Further, in 2021, the authors utilized
neural network (CNN)-based architecture with a dropout the transfer learning mechanism (Weimann and Conrad
mechanism and initially used wavelet filters to reduce the 2021) as it is expensive to acquire many annotated sam-
noise from ECG signal (Xu and Liu 2020). The results ples. The network is initially tuned on a small set of data to
indicate that the proposed model achieves high classifica- classify Atrial Fibrillation, the most frequent type of heart
tion accuracy. arrhythmia. As a result, the initial pre-training increases the
In 2015, the authors (Kiranyaz et al. 2015) proposed an CNN’s performance. The related state-of-the-art along with
ECG classification system based on a 1D convolutional their features, advantages, and future scope is summarized
network on real patient data. The authors in their work in Table 1.
(Ruiz et al. 2018) used 2D-CNN to extract the features, The proposed study utilizes different deep learning
effective learning is done using standard CNN-AlexNet, models to overcome the challenges faced in different
and an accuracy of 90% is obtained. Further, the authors approaches as discussed above and summarized in Table 1.
proposed a transformed 2D-CNN classifier, in which each For instance, in our work, the use of two-dimensional
ECG beat was converted into a two-dimensional grayscale convolutional neural network (2D-CNN) has eliminated the
image, and the findings confirmed the excellent classifi- work of feature extraction, as in this, one-dimensional
cation accuracy (Jun et al. 2018). In 2018, authors (Zhai signals are converted into two-dimensional images; the
and Tin 2018) proposed an ECG classification system major advantage of performing this conversion is that no
based on a convolutional neural network that transforms mechanism for filtering of noise or feature extraction has to
the beats into a dual beat coupling matrix that captures beat be applied separately as convolution and max-pooling
morphology and beat-to-beat correlation, and the results layers automatically filter the noise before the acquisition
validate improvements over traditional methods. The of features. Furthermore, the utilization of Long- Short-
authors proposed a novel approach multi-canonical corre- Term Memory Network (LSTM) model is more beneficial
lation analysis (MCAA) based on very deep convolutional as it has the ability to apprehend different time scales that
neural networks (VDCNN) in the same year, employing enable to capture the subtle differences in ECG signals for
filters to minimize the noise, and results revealed the arrhythmia classification over convolutional neural net-
enhanced performance over existing methods (Amrani work (CNN).
et al. 2018). Further, more variants of convolutional neural This study is an effort to integrate both ideas detection
networks (Acharya et al. 2017; Li et al. 2018) have been and classification using deep learning-based models with
applied to optimize the performance of the classifiers. minimal dependency on pre-processing of ECG signals. To
In 2018, Yilidirim et al. (2018) proposed a bidirectional the best of our knowledge, there is no detailed work in the
LSTM network to classify ECG signals. In 2019, authors direction of a comparative study of different classifiers. As
(Yildirim et al. 2019) proposed a coded feature-based deep a result of the comparison study and implementation of an
LSTM network model to reduce the data size and identify ensemble learning model over a single model increases the
arrhythmia signals. In 2019, Gao et al. (2019) proposed a robustness and reliability of the models. The accomplished
long short-term network recurrent neural network model comparative study would make the medical experts’ jobs
with focal loss to detect arrhythmia and also to resolve the simpler because it will provide them with a better under-
imbalance problem of the dataset. Furthermore, in the same standing of how to utilize deep-learning models in the right
year, Wang et al. (2019) proposed a bidirectional LSTM direction. The novelty of the paper is to enrich the medical
with semantic encoding which eliminated the feature experts’ experience and classify as well as to detect
extraction step and obtained good classification accuracy. arrhythmia patients simultaneously.
Picon et al. (2019) proposed a deep learning model based

123
1640 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

Table 1 Summary of approaches


Research Features/classifier Advantages Future scope
paper

Rakshit et al. Noise filtering Effective tool for noise filtering Beneficial for automated
(2018) empirical mode decomposition Preservation of QRS complex waves diagnostic systems
Adaptive switching mean filter
Aspuru et al. Signal segmentation Low cost Can be used as cost effective
(2019) Linear regression Correctly detect points strategy
Yang et al. Feature selection Heartbeat information is not lost Beneficial for ECG automatic
(2018) Autoencoders Eliminates manual feature extraction analysis
Softmax regression
Casas et al. Bayesian classification models Automated detection More features can be included
(2018) Naı̈ve Bayes model Assign probability to provide more insight
into the nature of heartbeats
Li et al. (2017) Back-propagation neural network High classification accuracy Can be used for automatic
Feature extraction using wavelet packet Reduce dimensions of features identification of arrhythmia
decomposition Optimize weights of neural network
Genetic algorithm to optimize weights of
back-propagation neural network
Mustaqeem SVM based approach High multiclass classification accuracy Can work on other datasets too
et al. (2018) Wrapper based feature selection method Most relevant features are extracted
Error correction code
Savalia et al. Multi-Layer Perceptron Neural Network High accuracy Can be refined further
(2018) Convolutional neural network No need for feature extraction
Jun et al. Two-dimension convolutional neural network Transformation of ECG signals into images Can be integrated with a
(2018) (2D-CNN) High accuracy medical robot’s camera
Yildirim et al. Long short-term memory High Performance More categories can be
(2019) Convolutional Auto-Encoder Low computational cost included
Reduced size of signals Analysis for long-duration data
Wang et al. Bi-directional LSTM Eliminates extraction of features Can be applied in real practical
(2019) Stacked de-noising auto-encoders High computational efficiency applications

The subsequent sections elaborate the architecture and


the detailed working of different classifiers used for
arrhythmia detection and classification.

3 Models Design and Architecture

This section discusses the framework of the proposed study


in detail that describes the entire workflow of the research
work. The real-world MIT-BIH arrhythmia dataset is used
for the experimental study of arrhythmia detection. The
workflow is depicted in Fig. 2 in which ECG signals are
given as an input to the different models that are imple-
mented in the current research study. The models that are
implemented and practiced are Artificial Neural Networks Fig. 2 Workflow of the arrhythmia detection
(Jadhav et al. 2010; Mohapatra et al. 2019), One-Dimen-
sional Convolutional Neural Networks (1D-CNN), Two- Two-Dimensional Convolutional Neural Networks with
Dimensional Convolutional Neural Networks (2D-CNN), long short-term memory network (2D-CNN with LSTM),
ensemble model. The best models have been saved and

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1641

elaborated in the below sections as evaluated on the vali- numbers of neurons in the hidden layer have been varied,
dation set during the optimization process. The entire and this number of neurons achieves the best classification
workflow of the work is depicted in Fig. 2 and detailed in results as validated on testing and validation data. Each
the following sub-sections: neuron is fully connected to the input and output layers by
connection weights denoted by wij and wjk as shown in
3.1 Data Collection Fig. 3. The random values are initialized to the weights
initially, and then, weights are adjusted to minimize the
The ECG Heartbeat Categorization dataset (Moody and error. The hidden layer neuron is represented as given in
Mark 2001) that is a segmented and pre-processed version Eq. (2) where hðiÞ denotes a unit in the hidden layer, wi
of the MIT-BIT dataset is used for this research study. The denotes the weights, bðiÞ denotes the bias term and f
details of the dataset are given in Sect. 4.1. The next step is denotes the activation function.
to train the model using different classifiers. T
ðiÞ
h ¼ f ðwðiÞ hði1Þ þ bðiÞ Þ ð2Þ
3.2 Artificial Neural Networks: Training The ReLU activation function (Karlik and Olgac 2011)
the Model is used for both input and hidden layers as it does not
activate all the neurons simultaneously and is given as in
Firstly, the model is trained using artificial neural net- Eq. (3).
works. The model is configured with an input layer, a
single hidden layer, and an output layer. The architecture of fx; if x [ ¼ 0
f ðxÞ ¼ ð3Þ
f0; if x\0
artificial neural networks is shown in Fig. 3 below.
The input layer consists of 187 neurons, due to 187 The weighted sum of the inputs along with the bias
numbers of features in each heartbeat record of the training weight is given as an input to the hidden layer as given in
data. There is no computation at the input layer; hence, the Eq. (4) where OIi is the output from the ith unit of the input
output of the input layer is passed as an input to the hidden layer, bH is the bias input added to the hidden layer, h is the
layer as given in Eq. (1) where OI is the output of the input units in the hidden layer, f is the features in the input layer.
layer and II is the input to the input layer. Then, this is passed to the activation function as given in
O I ¼ II ð1Þ Eq. (3) that gives the output of the hidden layer as
OH ¼ f ðIH Þ.
Each neuron is fully connected to every other neuron in
the hidden layer following the input layer. The hidden layer
consists of 64 neurons following the input layer, the

Fig. 3 Architecture of artificial


neural network with output
classes as N: Normal beat, S:
Supraventricular premature
beat, V: Premature ventricular
contraction, F: Fusion of
ventricular and normal beat, Q:
Unclassifiable beat

123
1642 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

f X
X h calculations and the number of parameters sharing are
IH ¼ ðwij  OIi Þ þ bH ð4Þ reduced. The batch normalization and dropout operations
i¼1 j¼1 are applied to improve the model performance.
X
The output layer consists of 5 nodes, each representing olk ¼ /ð ieR ol1
i  wik þ bk Þ ð8Þ
k
the value for each output class that is five different heart-
beats classes. Thus, soft-max activation function (Agosti- The detailed architecture is shown in Fig. 4 and dis-
nelli et al. 2014) is used in this layer as given in Eq. (6) due cussed in the following subsections.
to multi-class classification problem, where IO is input to The input layer has 187 neurons, due to 187 numbers of
the output layer as given in Eq. (5) where c is the number features in each heartbeat record of the training data. The
of classes of the heartbeat signal,h is the units in the hidden input layer is connected further to the convolutional layer.
layer and the output is computed as OO ¼ /ðIO Þ. The classifier contains three convolutional layers that are
h X
X c responsible for feature extraction from the dataset using
IO ¼ ðwjk  OHj Þ þ bO ð5Þ multi-dimensional array-based filters known as kernels.
j¼1 k¼1 The 64 kernels are present in all the convolutional layers.
The size of kernels in each layer is 6, 3, and 3, respectively.
eIOj
/ðIO Þ ¼ P ð6Þ Each convolutional layer is followed by a max-pooling
eIOk layer to reduce the dimensionality. The classifier contains 3
k
max-pooling layers, and each max-pooling layer proceeds
The back-propagation training algorithm is used to train with one convolutional layer. The max-pooling layers have
the network, in its forward pass, the input is passed through kernel sizes of 3, 2, and 2, respectively. The ReLU acti-
the activation function to reach the output layer and in its vation function is used in each layer except the output layer
backward pass, the actual output is compared with the as given above in Eq. (3). The batch normalization process
desired output. This difference between the actual and is applied after each convolutional layer to improve the
desired outputs is known as error, thus to minimize the performance and stability of the classifier. The mean and
error, a gradient descent optimization algorithm is used by variance of the input layers are computed as given in
computing the partial error derivatives, dE as given in Eq. (9) and Eq. (10) where m is the number of records in
Eq. (7) where l is the learning rate (Hertz 2018). each batch; j is the number of batches; l is the mean and d
Dwij ¼ l½dE=dwij  ð7Þ is the variance of a batch (Ioffe and Szegedy 2015).

The classifier performance is evaluated and compared 1X m


l¼ xi ð9Þ
with other classifiers by calculation of the confusion m i¼1
matrix: TP (True Positives), FP (False Positives), TN (True
1X m
Negatives), FN (False Negatives). The overall results of d2 ¼ ðxi lÞ2 ð10Þ
m i¼1
accuracy are discussed in Sect. 4.
Then, the input layers are normalized using the above
3.3 One-Dimensional Convolutional Neural calculated mean and variance of batches as given in
Networks (1D-CNN): Training the Model Eq. (11) where xi is the normalized input and e is a
constant.
The next classifier that is used to train the model is 1D- xi l
CNN. It consists of an input layer comprising ECG signals xi ¼ pffiffiffiffiffiffiffiffiffiffiffi ð11Þ
as an input, multiple convolution layers, multiple max- d2 þe
pooling layers, fully connected layers, and a single output Further, the normalized input is scaled to obtain the
layer that classifies the heartbeat signals in the correct output of layer, yi as given in Eq. (12) where c and b are
category. The convolution of the input with the kernel learned during the training of the network.
involves the element-wise matrix multiplication problem of yi ¼ cxi þ b ð12Þ
each input unit resulting in a single value as given in
Eq. (8) where Rk is the range of the convolution kernel, olk The two fully connected dense layers are added after the
denotes the output in layer l received after passing the last max-pooling layer consisting of 64 and 32 nodes,
weighted sum of inputs along with bias weight through respectively. The output layer has 5 nodes, each repre-
Relu activation function /, wik is the weight between the senting the value for each output class. The soft-max
layers, bk is the bias weight (Isin and Ozdalili 2017). The activation function is used in this layer as given above in
size of the kernel is small as compared to the input; thus, Eq. (6) due to a multi-class classification problem, where

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1643

Fig. 4 One-dimensional convolutional neural network architecture (Conv: convolution; BN: batch normalization; AF: activation function; Relu:
rectified linear unit activation function

IO is input to the output layer. It is fully connected with the except the output layer as given above in Eq. (3). The batch
last dense layer. normalization process is applied after each convolutional
layer to improve the performance and stability of the
3.4 Two-Dimensional Convolutional Neural classifier. The dropout mechanism is applied to all con-
Networks (2D-CNN): Training the Model volutional layers with a dropout rate of 0.5 except the last
one. It is applied to reduce the interdependent learning
The next classifier that is used to train the model is 2D- between the neurons that helps in reducing the overfitting
CNN. In this, one-dimensional signals are converted into of the model, and hence, the training time is reduced for
two-dimensional images; the major advantage of per- each epoch. The GlobalAveragePooling2d layer is used
forming this conversion is that no mechanism for filtering just before the dense output layer to reduce the dimensions
of noise or feature extraction has to be applied separately as of the input to the last layer. The output layer has 5 nodes,
convolution and max-pooling layers automatically filter the each representing the value for each output class. The soft-
noise before the acquisition of features. Moreover, it max activation function is used in this layer as given above
resembles the diagnosis done by doctors through moni- in Eq. (6) due to a multi-class classification problem where
toring the ECG images (Jun et al. 2018). The detailed IO is input to the output layer. It is fully connected with the
architecture is shown in Fig. 5 and detailed in the following last dense layer.
subsections.
The input layer has 187*2 neurons, due to 187 numbers 3.5 Two-Dimensional Convolutional Neural
of features in each heartbeat record of the training data. Networks (2D-CNN) with Long Short-Term
The input layer is connected further to the convolutional Memory (LSTM): Training the Model
layer, and the classifier contains 5 convolutional layers.
The convolutional layer is responsible for feature extrac- The next classifier that is used to train the model is 2D-
tion from the dataset using multi-dimensional array-based CNN with Long Short-Term Memory (LSTM). The con-
filters also known as kernels. The five layers have 256, 512, volutional neural networks have the capability to process
512, 128, and 64 kernels, respectively, in the convolutional spatial or local data only; thus, a variant of the recurrent
layers. The size of kernels in the first layer is (10, 2), and neural network, Long Short-Term Memory Network
the rest layers have kernels of size (5, 1), respectively. (LSTM) is integrated with 2D-CNN as it has the capability
Each convolutional layer is followed by a max-pooling to learn the long-term dependencies of ECG signals (Picon
layer. The ReLU activation function is used in each layer et al. 2019). The LSTM has the ability to apprehend

123
1644 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

Fig. 5 Two-dimensional convolutional neural network architecture (Conv: Convolution; BN: batch normalization; AF: activation function; Relu:
rectified linear unit activation function)

Fig. 6 Two-dimensional convolutional neural network with LSTM architecture. (Conv: convolution; BN: batch normalization; AF: activation
function; Relu: rectified linear unit activation function

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1645

different time scales that enable to capture the subtle dif- xt ¼ dðWi :½ot1 ; it  þ bi ð14Þ
ferences in ECG signals for arrhythmia classification. The
St ¼ tanhðWC :½ot1 ; it  þ bC ð15Þ
detailed architecture is shown in Fig. 6 and discussed
below: The final cell state value is calculated by multiplying the
The input layer has 187*2 neurons, due to 187 numbers old state with /ðtÞ and then, adding the updated values as
of features in each heartbeat record of the training data. given in Eq. (16) below.
The input to the model is given as two-dimensional images Ct ¼ /ðtÞ  Ct1 þ xt  St ð16Þ
that are formed from given one-dimensional ECG signals.
The input layer is connected further to the convolutional The final output is based on the final state value, thus
layer. The classifier contains 3 convolutional layers that are initially; the sigmoid activation function is applied to
responsible for feature extraction from the dataset using acquire the required output as given in Eq. (17).
multi-dimensional array-based filters also known as ker- ot ¼ dðWO :½ot1 ; it  þ bO ð17Þ
nels. The three layers have 256, 512, and 512 kernels,
respectively, in the convolutional layers. The size of ker- This is then passed through the hyperbolic tangent
nels in the first layer is (10, 2), and the rest layers have activation function to let the value lie between -1 and 1 as
kernels of size (5, 1), respectively. The ReLU activation given in Eq. (18).
function is used in each layer except the output layer as ht ¼ ot  tanhðCt Þ ð18Þ
given above in Eq. (3). With the deepening of the layers,
The dense output layer is used as prediction is to be
the inputs to the layer might change after the updating of
done across five classes of category with soft-max activa-
weights during the back-propagation process that causes
tion function as given above in Eq. (6). The output of the
the learning algorithms to pursue a moving target. This
entire network is computed as OO ¼ /ðIO Þ where OO is the
variation in the distribution of inputs is known as internal
output of the output layer and /ðIO Þ is given as in Eq. (19).
covariate shift (Ioffe and Szegedy 2015). Thus, the batch
normalization process is applied after each convolutional eIOj
/ðIO Þ ¼ P ð19Þ
layer that systematizes the inputs for the mini-batch of each eIOk
layer. The batch normalization process is applied to k
improve the performance and stability of the classifier. The learning rate is set to 0.001, and the model is trained
Further, the dropout mechanism is applied to all convolu- for 59 epochs as these parameter values give better vali-
tional layers with a dropout rate of 0.5 except for the last dation accuracy as discussed in the results section. The
one. It is applied to reduce the interdependent learning cross-entropy error is calculated as soft-max activation
between the neurons that helps in reducing the overfitting function is used in the output layer and is given in Eq. (20)
of the model, and hence, the training time for each epoch is where t is the number of target classes that is five different
reduced. The LSTM layer is added before the dense output categories corresponding to heartbeats, p is the predicted
layer that is responsible to capture the data at different time probability in a specific class t, y is an indicator that
scales. It consists of 64 cells that help in learning order indicates if the record is classified successfully in the target
dependency between the successive signals of a heartbeat. class (Zhang and Sabuncu 2018).
The LSTM architecture works by taking the sequence of
Xm
ECG signals as input and passing it through the sigmoid Cross Entropy Loss; E ¼  yo;t logðpo;t Þ ð20Þ
activation function that takes into consideration the previ- t¼1
ous ot1 as well as the current information it as given in
Eq. (13) to predict the future state of the signals and out-
puts in the category of normal or arrhythmic class category 3.6 Ensemble Learning Algorithm: Training
corresponding to the state of the heartbeat signal. the Model
/ðtÞ ¼ dðWf :½ot1 ; it  þ bi ð13Þ The bagging algorithm is used to combine the two-di-
The further information to be stored depends on which mensional CNN and two-dimensional CNN with LSTM.
part of the information is to be updated; thus, sigmoid The architecture is shown in Fig. 7. The 2D-CNN and 2D-
activation function is used in the current study suggesting CNN with LSTM are selected as base models due to their
the correct type of class category to early diagnose the comparatively less performance. The idea is to combine
arrhythmia, and then, the hyperbolic tangent activation them in order to create a strong ensemble model that
function is used with updated values that can be added to achieves better performance. The results of individual
the current state as given in Eq. (14) and Eq. (15), classifiers and ensemble models are discussed in Sect. 4,
respectively (Agostinelli et al. 2014).

123
1646 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

Fig. 7 Ensemble Model

…….

…. ….
Original
Ensemble
Dataset Bootstrap Weak Model
Samples Learners

and comparison of different classifiers is discussed in detail 2018) is applied to convert the class into a binary vector of
in Sect. 4.2.6, respectively. length five due to the presence of five classes in the dataset.
It runs on multiple subsets of data from the original data Each column of the vector represents one output class, one
to achieve better accuracy and stability of the model. It of the columns in the vector is 1 and the rest are 0, the
averages the predicted probabilities values of the classifiers column with 1 represents the output class for that particular
as given in Eq. (21) where S is the sub-samples of the heartbeat signal. The signal plots for different types of
original data, wi denote the weak learners (Bauer and heartbeats are shown in Fig. 8a–e:
Kohavi 1999). The ensemble model helps in the reduction
in the variance of the prediction. 4.2 Performance Evaluation of Different
X
S Classifiers
1
EL ¼ probðwi ð:ÞÞ ð21Þ
S i¼1 This section describes the performance of the different
classifiers on the same sampled training and testing dataset.
The models are trained using the tensor flow framework in
python as this framework has the capability to hold inputs,
4 Experimental Results and Discussion
labels, features, activation functions, placeholders, weights,
biases, input layer neurons, hidden layer neurons, output.
4.1 Experimental Dataset
There is a specific tensor to hold the model’s output, and
then, it is compared with the actual output. Once the error
The real-world MIT-BIH arrhythmia dataset (Moody and
is reduced to a minimum value, the model is tested for
Mark 2001) is used for this research study that consists of
accuracy against the test data.
multiple ECG signals. It is one of the most significant ECG
databases. This database consists of 48 annotated records
4.2.1 Artificial Neural Networks
procured from 47 subjects studied by Arrhythmia Labora-
tory of Beth Israel Hospital in Boston between 1975 and
The Artificial Neural Network (ANN) classifier is trained
1979. The 60% of the records were gathered from inpa-
for 50 epochs, and an accuracy of 96.85% is achieved on
tients. In total, there are 109,446 heartbeat signals that are
the test data. The model accuracy and loss curves for the
split into training, validation, and test data in the ratio of
training and validation dataset are shown in Fig. 9a and b,
60%, 20%, and 20%. These signals are the recordings of 25
respectively. It is observed from curves that network con-
men in between the age of 32 to 89 years and 22 women in
verges and accuracy has increased in firm state and is
between the age of 23 to 89 years for the duration of
stabilized at 50 epochs.
30 min at 360 samples per second. The ECG signal data
The performance of the model is visualized using a
have a sampling frequency of 125 Hz and contain 188
confusion matrix as shown in Table 2 where each element
columns of which the last column represents the class of
in the matrix denotes the number of predictions estimated
the heartbeat signal. The data are pre-processed using
by the model for different heartbeat classes. The tenfold
oversampling technique (Barua et al. 2012) to balance the
cross-validation is used to assess the performance of the
dataset and to accurately categorize the data in the correct
classifier. The average classifications results for the test
class. As the current problem is a multi-class classification
data are shown in Table 2. The confusion matrix has eased
problem indicated through the output column of the dataset
the task of computing the evaluation metrics as the output
that represents five classes of the heartbeat signal: Normal
classes are not binary in nature. It is observed from the
Beat (N), Supraventricular ectopic beats (S), Ventricular
confusion matrix that the model is able to make accurate
ectopic beats (V), Fusion beats (F), and Unknown beats
predictions and discriminate among different classes.
(Q). Thus, initially, the hot-encoding algorithm (Li et al.

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1647

Fig. 8 a Signal plots for normal beat. b Signal plots for supraventricular ectopic beat. c Signal plots for ventricular ectopic beat. d Signal plots for
fusion beat. 8 e Signal plots for unknown beat

The evaluation metrics characterized in the confusion (FP) as given in Eq. (22). True positives (TP) indicate that
matrix (Sajjadi et al. 2018) is applied to showcase the data are classified into the correct category, and False
performance of models are as follows: Positive (FP) indicates that abnormal data are categorized
into the normal category.
4.2.1.1 Precision It is defined as the ratio of true positives TP
(TP) to the sum of true positives (TP) and false positives Precision ¼ ð22Þ
TP + FP

123
1648 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

Fig. 9 a Model accuracy curve for ANN classifier. b loss curve for ANN classifier

Table 2 Test data confusion matrix for the ANN classifier 4.2.1.4 Accuracy It is defined as the fraction of the total
records that are correctly classified by the model as given
N 0.98 0.01 0.01 0.00 0.00
in Eq. (25). The higher value of accuracy indicates that
True Class S 0.19 0.77 0.03 0.01 0.01 data are classified appropriately.
V 0.03 0.00 0.95 0.02 0.00 TP + TN
F 0.07 0.01 0.08 0.83 0.00 Accuracy ¼ ð25Þ
TP + TN + FP + FN
Q 0.01 0.00 0.01 0.00 0.98
N S V F Q
4.2.1.5 F1-Score It is defined as the harmonic mean of
Predicted class
precision and recall as given in Eq. (26).
Precision  Recall
F1  Score ¼ 2  ð26Þ
Precision þ Recall
The confusion matrix shows that utilizing artificial
4.2.1.2 Recall or Sensitivity It is defined as the ratio of neural networks to train the model resulted in a precision of
true positives (TP) to the sum of true positives (TP) and 82%, recall or sensitivity of 90%, specificity of 97.5%, F1-
false negatives (FN) as given in Eq. (23) where true posi- score of 86%, and accuracy of 97%.
tives (TP) indicate that data are classified into the correct
category and false negatives (FN) indicate that normal data 4.2.2 One-Dimensional Convolutional Neural Networks
are categorized into the abnormal category. (1D-CNN)
TP
Recall ¼ ð23Þ The 1D-CNN classifier is trained just for 10 epochs and
TP + FN
within this number of epochs, an accuracy of 98.04% is
achieved on the test data. The model accuracy and loss
4.2.1.3 Specificity It is defined as the ratio of true nega- curves for the training and validation dataset are shown in
tives (TN) to the sum of true negatives (TN) and false Fig. 10a and b, respectively. It is observed that accuracy
positives (FP) as given in Eq. (24) where true negatives has increased in the firm state and is stabilized within 10
(TN) indicate that data are classified into the correct cat- epochs.
egory and false positives (FP) indicate that abnormal data The performance of the model is evaluated on test data
are categorized into the normal category. and is visualized using a confusion matrix as shown in
TN Table 3 where each element in the matrix denotes the
Specificity ¼ ð24Þ
TN þ FP number of predictions estimated by the model. The large
values of the correct responses shown in bold indicate the
high accuracy of the classifier. The evaluation measures

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1649

Fig. 10 a Model accuracy curve for 1D-CNN classifier. b Model loss curve for 1D-CNN classifier

Table 3 Test data confusion matrix for the 1D-CNN classifier defined above in Eqs. (22), (23), (24), (25) and (26),
respectively.
N 0.99 0.01 0.00 0.00 0.00
The confusion matrix shows that training the model with
True Class S 0.19 0.78 0.02 0.01 0.01 two-dimensional convolutional neural networks resulted in
V 0.04 0.00 0.94 0.01 0.00 a precision of 80%, recall of 94%, specificity of 98.5%, F1-
F 0.09 0.00 0.11 0.80 0.00 score of 95%, and accuracy of 96%.
Q 0.01 0.00 0.00 0.00 0.99
N S V F Q 4.2.4 Two-Dimensional Convolutional Neural Networks
Predicted class (2D-CNN) with LSTM

The 2D-CNN with LSTM classifier is trained for 59 epochs


before the loss of the model plateaued, and an accuracy of
used for the performance evaluation are defined above in 94.9% is achieved on the test data. The model accuracy and
Eqs. (22), (23), (24), (25) and (26), respectively. loss curves for the training and validation dataset are
The confusion matrix shows that utilizing one-dimen- shown in Fig. 12a and b. It is observed that accuracy has
sional convolutional neural networks to train the model increased in a firm state and stabilized within 59 epochs.
resulted in the precision of 90%, recall of 90%, specificity The performance of the model is evaluated on test data
of 97.4%, F1-score of 90%, and accuracy of 98%. and is visualized using a confusion matrix as shown in
Table 5 where each element in the matrix denotes the
4.2.3 Two-Dimensional Convolutional Neural Networks number of predictions estimated by the model. The eval-
(2D-CNN) uation measures used for the performance evaluation are
defined above in Eqs. (22), (23), (24), (25) and (26),
The 2D-CNN classifier is trained just for 38 epochs before respectively.
the loss of the model is fixed, and an accuracy of 95.6% is It is observed from the confusion matrix that training the
achieved on the test data. The model accuracy and loss model using two-dimensional convolutional neural net-
curves for the training and validation dataset are shown in works with LSTM has achieved a precision of 78%, a recall
Fig. 11a and b. It is observed that accuracy has increased in of 93%, specificity of 98.4%, F1- score of 83%, and an
a firm state and stabilized within 38 epochs. accuracy of 95%.
The performance of the model is evaluated on test data
and is visualized using a confusion matrix as shown in 4.2.5 Ensemble Model
Table 4 where each element in the matrix denotes the
number of predictions estimated by the model. The eval- The 2D-CNN and 2D-CNN with LSTM classifier is com-
uation measures used for the performance evaluation are bined using a bagging algorithm. The accuracy of 96.2% is

123
1650 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

Fig. 11 a Model accuracy curve for 2D-CNN classifier. b Loss curve for 2D-CNN classifier

Table 4 Test data confusion matrix for the 2D-CNN classifier measures used for the performance evaluation are defined
above in Eqs. (22), (23), (24), (25) and (26), respectively.
N 0.96 0.04 0.00 0.00 0.00
The confusion matrix shows that training the model with
True Class S 0.08 0.91 0.01 0.01 0.00 ensemble model resulted in a precision of 87.2%, recall of
V 0.02 0.01 0.95 0.02 0.00 96.9%, specificity of 98.6%, F1-score of 91.8%, and
F 0.03 0.02 0.05 0.90 0.00 accuracy of 96.2%. The TPR and FPR values are shown in
Q 0.00 0.00 0.00 0.00 0.99 Table 7.
N S V F Q
Predicted class 4.2.6 Comparison of Different Classifiers

The performance of the different classifiers is measured


using different metrics that are accuracy, precision, recall,
achieved using ensemble learning as shown in Fig. 13. The and F1-score as shown in Fig. 13. The ECG dataset is
performance of the model is evaluated on test data and is randomly divided into 10 equal folds. The eightfolds are
visualized using the confusion matrix as shown in Table 6 used for the training set, and remaining two folds are used
where each element in the matrix denotes the number of for the test and validation set, respectively. The model
predictions estimated by the model. The evaluation producing the best validation results are used further for

Fig. 12 a Model accuracy curve for 2D-CNN with LSTM. b Loss curve for 2D-CNN with LSTM

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1651

Table 5 Test data confusion matrix for the 2D-CNN with LSTM Table 6 Test data confusion matrix for the ensemble model
classifier
N 0.96 0.03 0.00 0.00 0.00
N 0.95 0.04 0.00 0.00 0.00
True Class S 0.08 0.91 0.01 0.00 0.00
True Class S 0.10 0.88 0.01 0.00 0.00 V 0.02 0.01 0.95 0.02 0.00
V 0.02 0.01 0.94 0.02 0.00 F 0.04 0.01 0.04 0.91 0.00
F 0.04 0.01 0.04 0.91 0.00 Q 0.00 0.00 0.00 0.00 0.99
Q 0.01 0.00 0.00 0.00 0.99 N S V F Q
N S V F Q Predicted class
Predicted class

Table 7 True positive rate and false positive rate of every classifier
for test data
evaluation of the test folds. The average classification
results for every classifier are depicted in Fig. 14 below. Classifier TPR FPR
Through experimentation, it has been observed that one- ANN 0.89 0.005
dimensional convolutional neural network achieves the 1D-CNN 0.75 0.002
highest accuracy of 98%, artificial networks have an 2D-CNN 0.88 0.01
accuracy of 97%, two-dimensional convolutional neural 2D-CNN with LSTM 0.84 0.01
networks and ensemble classifiers have comparable accu- Ensemble 0.87 0.007
racy of 96% and convolutional neural network with LSTM
has an accuracy of 95%. The utilization of deep learning
models has achieved promising results for arrhythmia TP
TPR ¼ ð27Þ
classification. This enables the medical experts to diagnose TP + FN
arrhythmia at early stages that can save more human lives. FP
FPR ¼ ð28Þ
Further, the performance of various classifiers for test FP þ TN
data is also assessed using the ROC curve that displays the
The ROC curve goes through the top-left corner for a
true positive rate (TPR) against the false positive rate
good classification method. It is evident from the above
(FPR) at different threshold values, as illustrated in Fig. 14.
Fig. 14 that area under the curve for 1D-CNN is higher
The true positive rate is defined as the proportion of the
than the other classifiers, then the ANN classifier is better
actual positives that are correctly determined as given in
in discrimination among the different output classes, the
Eq. (27), while the false positive rate is defined as the
2D-CNN and ensemble classifiers have comparable per-
proportion of the negatives that are incorrectly classified as
formance, and finally, 2D-CNN with LSTM classifier has
positive as given in Eq. (28).
similar performance.

Fig. 13 Accuracy, precision,


recall and F1-score of every
classifier

123
1652 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

Fig. 14 ROC Curve of every


classifier for Test Data

5 Discussion authors in their work (Yildirim et al. 2019) implemented a


long short-term network (LSTM) with a convolutional
The current research study is inspired by previous studies auto-encoder (CAE) that compresses the ECG signals on an
in this area. Several studies have been carried out to average of about 70% and achieved an accuracy of over
automate the task of heart arrhythmia detection using deep 99%. Further, the authors in their work (Wang et al. 2019)
learning-based models (Acharya et al. 2017; Gao et al. used a bi-directional LSTM classifier with stacked
2019; Isin and Ozdalili 2017; Kiranyaz et al. 2015; Li et al. denoising auto-encoders (SDAE) that learns the semantic
2018). This study is a novel effort to provide a unified encoding of heartbeats and the findings show that the study
comparison of several deep learning-based models such as obtained high classification accuracy.
Artificial Neural Networks, 1D-CNN, 2D-CNN, 2D-CNN The most recent work published in this area is by Cui
with LSTM, and ensemble classifiers that would give a et al. in September 2021 in which authors claimed that
deeper insight to the researchers working in this domain. extracted features using 1D CNN and wavelet transform
For instance, Xu et al. (2020) in their study used cou- are optimal features that makes it better than the existing
pled-convolution layer architecture and attained an overall models. In our work, we are able to achieve this same
accuracy of 99.43% and the findings conclude that the accuracy of 1D CNN without wavelet transform. The
model performed better in the categorization of the ven- comparison in terms of correct class-wise accuracy is
tricular ectopic beat (VEB) and supraventricular ectopic comparable.
beat (SVEB). In addition, Hannun et al. (2019) in their To the best of our knowledge, this is a detailed com-
work used a deep neural network (DNN) to classify 12 parative study that comprehensively evaluates the perfor-
classes and attained an area under the curve of 0.97 and an mance of different classifiers. The analysis of the results
F1- score of 0.837. The authors in their work (Zhai and Tin indicates that the implementation of the deep learning-
2018) encoded the beats into a dual beat coupling matrix, based models including artificial neural networks, 1D-
and this encoded 2D-CNN-based classifier outperformed CNN, 2D-CNN, 2D-CNN with LSTM, and ensemble
previous state-of-the-art approaches. Similarly, authors in classifiers resulted in an accuracy of over 95% for each
their work (Kiranyaz et al. 2015) used 1D-CNN on patient- classifier. Though the models have achieved good accuracy
specific data and obtained better accuracy for ventricular but still further refinements might be required to test for
ectopic beat (VEB) and supraventricular ectopic beats other real ECG datasets. The advanced network architec-
(SVEB) classification. tures can be used to further enhance the classification
Jun et al. (2018) in their work developed a transformed accuracy. The work can be extended to detect different
deep 2D-CNN, tested on the MIT-BIH arrhythmia data- kinds of arrhythmia and other heart diseases with high
base, and achieved an accuracy of 99.05% with 97.85% accuracy from ECG records. The findings show that deep
sensitivity. Moreover, to hold the temporal information the learning models have a significant impact on the

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1653

automation of heart arrhythmia detection and classification. References


This research could aid medical professionals in making an
accurate diagnosis of arrhythmia. Acharya UR, Oh SL, Hagiwara Y, Tan JH, Adam M, Gertych A, San
Tan R (2017) A deep convolutional neural network model to
classify heartbeats. Comput Biol Med 89:389–396
Agante PM, De Sá JM (1999) ECG noise filtering using wavelets with
6 Conclusion and Future Work soft-thresholding methods. In: Computers in cardiology 1999.
Vol 26 (Cat. No. 99CH37004) pp 535–538. IEEE
Heart arrhythmia is defined as irregularities in the heart- Agostinelli F, Hoffman M, Sadowski P, Baldi P (2014) Learning
activation functions to improve deep neural networks. arXiv
beats, but analysis of ECG signals and accurate recognition preprint https://arxiv.org/abs/1412.6830
of ECG components is itself a complex task. Therefore, an Amrani M, Hammad M, Jiang F, Wang K, Amrani A (2018) Very
automated system is required to accurately diagnose deep feature extraction and fusion for arrhythmias detection.
arrhythmia. Thus, early heart arrhythmia detection and Neural Comput Appl 30(7):2047–2057
Ashley EA, Niebauer J (2004) Cardiology explained
classification is an active area of research. This study Aspuru J, Ochoa-Brust A, Félix RA, Mata-López W, Mena LJ, Ostos
automates the task of arrhythmia detection and classifica- R, Martı́nez-Peláez R (2019) Segmentation of the ECG Signal by
tion using deep learning models. The classification results means of a linear regression algorithm. Sensors 19(4):775
show that one-dimensional convolutional neural networks Association for the Advancement of Medical Instrumentation (1998)
Testing and reporting performance results of cardiac rhythm and
achieve the highest accuracy of 98%, artificial neural net- ST segment measurement algorithms. ANSI/AAMI EC 38:1998
works reach an accuracy of 97%, two-dimensional con- Barua S, Islam MM, Yao X, Murase K (2012) MWMOTE–majority
volutional neural networks achieve an accuracy of 96%, weighted minority oversampling technique for imbalanced data
two-dimensional convolutional neural networks with set learning. IEEE Trans Knowl Data Eng 26(2):405–425
Bauer E, Kohavi R (1999) An empirical comparison of voting
LSTM reach an accuracy of 95%, and an ensemble model classification algorithms: bagging, boosting, and variants. Mach
that is a combination of two-dimensional CNN and two- Learn 36(1–2):105–139
dimensional convolutional neural networks with LSTM Casas MM, Avitia RL, Gonzalez-Navarro FF, Cardenas-Haro JA,
also has comparable accuracy of 96%. Thus, the applica- Reyna MA (2018) Bayesian classification models for premature
ventricular contraction detection on ECG traces. J Healthcare
bility of deep learning models in this direction has proved Eng. https://doi.org/10.1155/2018/2694768
to be promising. Cui J, Wang L, He X, De Albuquerque VHC, AlQahtani SA, Hassan
In the future, the work can be extended in the following MM (2021) Deep learning-based multidimensional feature
research directions: fusion for classification of ECG arrhythmia. Neural Comput
Appl. https://doi.org/10.1007/s00521-021-06487-5
1. The current study can be extended to include more Dai H, Hwang HG, Tseng VS (2021) Convolutional neural network
based automatic screening tool for cardiovascular diseases using
categories of arrhythmia.
different intervals of ECG signals. Comput Methods Progr
2. The proposed models can be integrated with an Biomed 203:106035
android application to make them real-time and easily de Albuquerque VHC, Nunes TM, Pereira DR, Luz EJDS, Menotti D,
available for commercial purposes. Papa JP, Tavares JMR (2018) Robust automated cardiac
arrhythmia detection in ECG beat signals. Neural Comput Appl
3. It can be further tuned with medical cameras.
29(3):679–693
4. It can be evaluated on other real-world datasets as well De Chazal P, O’Dwyer M, Reilly RB (2004) Automatic classification
as data from hospitals. of heartbeats using ECG morphology and heartbeat interval
features. IEEE Trans Biomed Eng 51(7):1196–1206
This study provides a detailed comparative study for Gao J, Zhang H, Lu P, Wang Z (2019) An effective LSTM recurrent
arrhythmia detection and classification using various deep network to detect arrhythmia on imbalanced ECG dataset.
learning models. The study would be beneficial for medical J Healthcare Eng. https://doi.org/10.1155/2019/6320651
Gayathri S, Suchetha M, Latha V (2012) ECG arrhythmia detection
experts to potentially diagnose arrhythmia earlier and save and classification using relevance vector machine. Procedia Eng
more human lives due to heart disorders. It has been 38:1333–1339
observed that medical experts could use deep learning- Hagiwara Y, Fujita H, Oh SL, Tan JH, San Tan R, Ciaccio EJ,
based models to diagnose additional heart-related disorders Acharya UR (2018) Computer-aided diagnosis of atrial fibrilla-
tion based on ECG signals: a review. Inf Sci 467:99–114
too based on ECG readings. Hannun AY, Rajpurkar P, Haghpanahi M, Tison GH, Bourn C,
Turakhia MP, Ng AY (2019) Cardiologist-level arrhythmia
detection and classification in ambulatory electrocardiograms
using a deep neural network. Nat Med 25(1):65
Declarations Hertz JA (2018) Introduction to the theory of neural computation.
CRC Press
Conflict of Interest The authors have no conflicts of interest to declare Hou B, Yang J, Wang P, Yan R (2019) LSTM-based auto-encoder
that are relevant to the content of this article. model for ecg arrhythmias classification. IEEE Trans Instrum
Meas 69(4):1232–1240

123
1654 Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655

Hu YH, Palreddy S, Tompkins WJ (1997) A patient-adaptable ECG Pławiak P, Acharya UR (2020) Novel deep genetic ensemble of
beat classifier using a mixture of experts approach. IEEE Trans classifiers for arrhythmia detection using ECG signals. Neural
Biomed Eng 44(9):891–900 Comput Appl 32(15):11137–11161
Ioffe S, Szegedy C (2015) Batch normalization: accelerating deep Polat K, Güneş S (2007) Detection of ECG arrhythmia using a
network training by reducing internal covariate shift. arXiv differential expert system approach based on principal compo-
preprint https://arxiv.org/abs/1502.03167 nent analysis and least square support vector machine. Appl
Isin A, Ozdalili S (2017) Cardiac arrhythmia detection using deep Math Comput 186(1):898–906
learning. Procedia Comput Sci 120:268–275 Poungponsri S, Yu XH (2013) An adaptive filtering approach for
Jadhav SM, Nalbalwar SL, Ghatol A (2010) Artificial neural network electrocardiogram (ECG) signal noise reduction using neural
based cardiac arrhythmia classification using ECG signal data. networks. Neurocomputing 117:206–213
In: 2010 international conference on electronics and information Rajkumar A, Ganesan M, Lavanya R (2019) Arrhythmia classification
engineering, Vol 1, pp V1–228. IEEE on ECG using deep learning. In: 2019 5th international confer-
Jambukia SH, Dabhi VK, Prajapati HB (2015) Classification of ECG ence on advanced computing and communication systems
signals using machine learning techniques: a survey. In: 2015 (ICACCS) pp 365–369. IEEE
international conference on advances in computer engineering Rakshit M, Das S (2018) An efficient ECG denoising methodology
and applications, pp 714–721. IEEE using empirical mode decomposition and adaptive switching
Jun TJ, Nguyen HM, Kang D, Kim D, Kim D, Kim YH (2018) ECG mean filter. Biomed Signal Process Control 40:140–148
arrhythmia classification using a 2-D convolutional neural Ramkumar M, Babu CG, Priyanka GS, Kumar RS (2021) Ecg
network. arXiv preprint https://arxiv.org/abs/1804.06812 arrhythmia signals classification using particle swarm optimiza-
Karlik B, Olgac AV (2011) Performance analysis of various tion-support vector machines optimized with independent com-
activation functions in generalized MLP architectures of neural ponent analysis. In IOP Conference Series: Materials Science
networks. Int J Artif Intell Expert Syst 1(4):111–122 and Engineering, Vol 1084, No 1, p 012009. IOP Publishing
Karpagachelvi S, Arthanari M, Sivakumar M (2010) ECG feature Ruiz JT, Pérez JDB, Blázquez JRB (2018) Arrhythmia detection
extraction techniques-a survey approach. arXiv preprint https:// using convolutional neural models. In: International symposium
arxiv.org/abs/1005.0957 on distributed computing and artificial intelligence, pp 120–127.
Khatibi T, Rabinezhadsadatmahaleh N (2020) Proposing feature Springer, Cham
engineering method based on deep learning and K-NNs for ECG Sadiq JS, Arunmani G, Ravivarma P, Devi NK, Hemalatha A,
beat classification and arrhythmia detection. Phys Eng Sci Med Ahamed JE (2021) Extraction of fetal ECG a semi-blind source
43(1):49–68 separation algorithm combined with parametrized kalman filter.
Kiranyaz S, Ince T, Gabbouj M (2015) Real-time patient-specific In: Materials today: proceedings
ECG classification by 1-D convolutional neural networks. IEEE Sajjadi MS, Bachem O, Lucic M, Bousquet O, Gelly S (2018)
Trans Biomed Eng 63(3):664–675 Assessing generative models via precision and recall. In:
Li H, Yuan D, Ma X, Cui D, Cao L (2017) Genetic algorithm for the Advances in neural information processing systems,
optimization of features and neural networks in ECG signals pp 5228–5237
classification. Sci Rep 7:41011 Salem M, Taheri S, Yuan JS (2018) ECG arrhythmia classification
Li J, Si Y, Xu T, Jiang S (2018) Deep convolutional neural network using transfer learning from 2-dimensional deep CNN features.
based ECG classification system using information fusion and In 2018 IEEE biomedical circuits and systems conference
one-hot encoding techniques. Math Probl Eng. https://doi.org/10. (BioCAS), pp 1–4. IEEE
1155/2018/7354081 Sameni R, Shamsollahi MB, Jutten C, Babaie-Zade M (2005)
Luz EJDS, Schwartz WR, Cámara-Chávez G, Menotti D (2016) ECG- Filtering noisy ECG signals using the extended Kalman filter
based heartbeat classification for arrhythmia detection: a survey. based on a modified dynamic ECG model. In: Computers in
Comput Methods Progr Biomed 127:144–164 cardiology, pp 1017–1020. IEEE
Mitra M, Samanta RK (2013) Cardiac arrhythmia classification using Savalia S, Emamian V (2018) Cardiac arrhythmia classification by
neural networks with selected features. Procedia Technol multi-layer perceptron and convolution neural networks. Bio-
10:76–84 engineering 5(2):35
Mohapatra SK, Srivastava G, Mohanty MN (2019) Arrhythmia Sayadi O, Shamsollahi MB (2009) A model-based Bayesian frame-
classification using deep neural network. In 2019 International work for ECG beat segmentation. Physiol Meas 30(3):335
Conference on Applied Machine Learning (ICAML), Sellami A, Hwang H (2019) A robust deep convolutional neural
pp 296–300. IEEE network with batch-weighted loss for heartbeat classification.
Moody GB, Mark RG (2001) The impact of the MIT-BIH arrhythmia Expert Syst Appl 122:75–84
database. IEEE Eng Med Biol Mag 20(3):45–50 Tsipouras MG, Fotiadis DI (2004) Automatic arrhythmia detection
Mustaqeem A, Anwar SM, Majid M (2018) Multiclass classification based on time and time–frequency analysis of heart rate
of cardiac arrhythmia using improved feature selection and SVM variability. Comput Methods Progr Biomed 74(2):95–108
invariants. Comput Math Methods Med. https://doi.org/10.1155/ Vijaya V, Rao KK, Rama V (2011) Arrhythmia detection through
2018/7310496 ECG feature extraction using wavelet analysis. Eur J Sci Res
Nasiri JA, Naghibzadeh M, Yazdi HS, Naghibzadeh B (2009) ECG 66(3):441–448
arrhythmia classification with support vector machines and Wang EK, Zhang X, Pan L (2019) Automatic classification of CAD
genetic algorithm. In: 2009 Third UKSim European symposium ECG signals with SDAE and bidirectional long short-term
on computer modeling and simulation, pp 187–192. IEEE network. IEEE Access 7:182873–182880
Osowski S, Hoai LT, Markiewicz T (2004) Support vector machine- Weimann K, Conrad TO (2021) Transfer learning for ECG classi-
based expert system for reliable heartbeat recognition. IEEE fication. Sci Rep 11(1):1–12
Trans Biomed Eng 51(4):582–589 Xu X, Liu H (2020) ECG heartbeat classification using convolutional
Picon A, Irusta U, Álvarez-Gila A, Aramendi E, Alonso-Atienza F, neural networks. IEEE Access 8:8614–8619
Figuera C, Eftestøl T (2019) Mixed convolutional and long Yang J, Bai Y, Lin F, Liu M, Hou Z, Liu X (2018) A novel
short-term memory network for the detection of lethal ventric- electrocardiogram arrhythmia classification method based on
ular arrhythmia. PLoS ONE 14(5):e0216756

123
Iranian Journal of Science and Technology, Transactions of Electrical Engineering (2023) 47:1635–1655 1655

stacked sparse auto-encoders and softmax regression. Int J Mach Zhang Z, Sabuncu M (2018) Generalized cross entropy loss for
Learn Cybern 9(10):1733–1740 training deep neural networks with noisy labels. In: Advances in
Ye C, Kumar BV, Coimbra MT (2012) Heartbeat classification using neural information processing systems, pp 8778–8788
morphological and dynamic features of ECG signals. IEEE Ziarani AK, Konrad A (2002) A nonlinear adaptive method of
Trans Biomed Eng 59(10):2930–2941 elimination of power line interference in ECG signals. IEEE
Yildirim Ö (2018) A novel wavelet sequence based on deep Trans Biomed Eng 49(6):540–547
bidirectional LSTM network model for ECG signal classifica-
tion. Comput Biol Med 96:189–202
Springer Nature or its licensor (e.g. a society or other partner) holds
Yildirim O, Baloglu UB, Tan RS, Ciaccio EJ, Acharya UR (2019) A
exclusive rights to this article under a publishing agreement with the
new approach for arrhythmia classification using deep coded
author(s) or other rightsholder(s); author self-archiving of the
features and LSTM networks. Comput Methods Progr Biomed
accepted manuscript version of this article is solely governed by the
176:121–133
terms of such publishing agreement and applicable law.
Zhai X, Tin C (2018) Automated ECG classification using dual
heartbeat coupling based on convolutional neural network. IEEE
Access 6:27465–27472

123

You might also like