AttBiLFNet: A Novel Hybrid Network for Accurate and Efficient Arrhythmia Detection in Imbalanced ECG Signals

: Within the domain of cardiovascular diseases, arrhythmia is one of the leading anomalies causing sudden deaths. These anomalies, including arrhythmia, are detectable through the electrocardiogram, a pivotal component in the analysis of heart diseases. However, conventional methods like electrocardiography encounter challenges such as subjective analysis and limited monitoring duration. In this work, a novel hybrid model AttBiLFNet, is proposed for precise arrhythmia detection in ECG signals included imbalanced class distributions. AttBiLFNet integrates a Bidirectional Long Short-Term Memory (BiLSTM) network with a Convolutional Neural Network (CNN) and incorporates an attention mechanism using the focal loss function. This architecture is capable of autonomously extracting features by harnessing BiLSTM's bidirectional information flow, which proves advantageous in capturing long-range dependencies. The attention mechanism enhances the model's focus on pertinent segments of the input sequence, particularly beneficial in class imbalance classification scenarios where minority class samples tend to be overshadowed. The focal loss function effectively addresses the impact of class imbalance, thereby improving overall classification performance. The proposed AttBiLFNet model achieves 99.55% accuracy and 98.52% precision. Moreover, performance metrics such as MF1, K score, and sensitivity are calculated, and the model is compared with various methods in the literature. Empirical evidence clearly shows that AttBiLFNet outperforms existing methods in terms of both accuracy and computational efficiency. The introduced model serves as a reliable tool for the timely identification of arrhythmias


Introduction
Cardiovascular diseases (CVDs) pose a significant threat to human health worldwide.Data from the World Health Organization (WHO) indicate that CVDs are the leading cause of death globally, resulting in 17.9 million fatalities annually, comprising approximately 32% of all global deaths.Over 75% of these fatalities occur in developing nations.The prevalence and mortality rates of CVDs are steadily increasing at alarming levels.Consequently, regular heart rhythm monitoring has emerged as an essential and indispensable strategy for effectively managing and preventing CVDs [1,2].
The electrocardiogram (ECG) is a cornerstone of clinical arrhythmia diagnosis.This non-invasive method provides a detailed view of the heart's electrical activity, revealing the timing and coordination of atrial and ventricular contractions.The most widely applied solution for arrhythmia detection is electrocardiography, which records the electrical activity of the heart over a period using electrodes placed over the skin, as illustrated in Figure 1 [3].By analyzing the ECG's waveforms, healthcare professionals can assess the efficiency of impulse conduction through the heart's conduction system, including the atria, atrioventricular (AV) junction, and ventricles.The procedure involves attaching twelve electrodes to specific locations on the body, four on the limbs and six on the chest.These electrodes act as sensors, capturing the heart's electrical signals and transmitting them to an ECG machine for analysis and interpretation [4][5][6].Traditional arrhythmia monitoring methods, such as Holter monitors and event recorders, are limited by their short-term recording capabilities, often restricting continuous patient surveillance.To address this limitation and enhance the duration and quality of arrhythmia screening, smart wearable devices have emerged as a promising alternative.These devices, including smartwatches, clothing-integrated sensors, and chest patches, enable continuous monitoring of arrhythmias, providing valuable insights into cardiac rhythm patterns over extended periods.Their ability to capture arrhythmic events throughout daily activities offers clinicians a more comprehensive understanding of patient cardiovascular health [7].However, it is important to note that the acquisition of ECG signals can be affected by various challenges.These challenges include the absence of cardiac arrhythmia indicators during capture, non-stationary ECG signal morphology, patient-specific ECG signal properties, large volumes of ECG data, and the presence of noise and artifacts.These challenges can lead to inaccurate interpretations of cardiac arrhythmias [8][9][10][11].In addition, traditional ECG analysis is subjective, time-consuming, and limited in its ability to detect subtle changes in heart function due to its reliance on the expertise of the interpreting physician [12].The use of machine learning (ML) and deep learning (DL) models in ECG interpretation has the potential to improve healthcare access and outcomes in remote or resource-limited settings.These models can provide continuous, real-time monitoring and more accurate interpretation of ECG signals, thereby increasing the likelihood of capturing intermittent arrhythmias.Additionally, the use of ML and DL models can standardize analyses, reducing the variability inherent in human interpretation and potentially leading to improved patient outcomes.Therefore, it is essential to foster research and development in the field of ML to realize its full potential benefits [13,14].A review of extant literature reveals that traditional ML algorithms, which employ handcrafted features, are commonly employed as the initial step in the model development process.The utilization of a shallow learning model in conjunction with a feature extractor is a particularly prevalent approach in this regard [15].Several researchers [15][16][17][18][19][20][21] have utilized advanced mathematical techniques, such as higher-order statistics (HOS), continuous wavelet transform, independent component analysis (ICA), and principal component analysis (PCA), to extract meaningful features from data [22].Conventional classifier networks, including random forest, support vector machine, and k-nearest neighbors, were trained on these extracted features.However, the achieved results fell short of expectations, and the feature extraction process proved to be time-consuming.Additionally, a significant drawback of these methods lies in the dataset-specific nature of the extracted features, hindering generalization capabilities.Because of these disadvantages, deep learning algorithms such as convolutional neural networks (CNNs) have been adopted to extract features automatically.Despite significant advancements in arrhythmia detection, both traditional classifiers [23][24][25] and deep learning-based classifiers [26][27][28] struggle to effectively handle class imbalance.This is primarily due to the inherent nature of ECG signals, where acquiring equal amounts of data for each class of arrhythmias is often impractical.Conventional classifier networks, on the other hand, require substantial amounts of balanced data from each class to achieve optimal performance [29].To address this challenge, various techniques have been explored, including Siamese Neural Networks [30], long short-term memory (LSTM) networks [31], and bidirectional LSTM (BiLSTM) networks [22].While these methods have shown some improvement in classification accuracy, they have yet to reach the desired levels of performance.
In recent years, there has been a surge of research dedicated to addressing the challenge of class imbalance in various domains.One noticeable contribution is the work of Lin et al. (2017) in the object detection field [32].They introduced the focal loss function, an enhanced version of the categorical cross-entropy loss function commonly employed in CNNs.Subsequently, focal loss has been incorporated into DL techniques in various fields, including time series analysis [33], speech recognition [34], and natural language processing [35].A particularly noteworthy study in this area is that of Petmezas et al. (2021) on an imbalanced ECG dataset [36].This work utilizes a hybrid network architecture combining an LSTM and a CNN, with focal loss selected as the loss function.The CNN component serves as a feature extractor, while the LSTM acts as an information selector, learning the temporal dynamics of the input data.This study effectively demonstrates the superior performance of CNN-LSTM with focal loss in handling class imbalance [36].
While the combination of CNN and LSTM proves effective in handling class imbalance, further improvements can be achieved by replacing the LSTM with a BiLSTM.BiLSTMs offer several advantages over LSTMs, particularly in the context of imbalanced data classification.LSTMs, with their unidirectional flow of information, can sometimes miss important contextual information, especially when dealing with long sequences or when the relevant information is spread out across the sequence.BiLSTMs, on the other hand, process the input sequence in both directions, allowing them to capture long-range dependencies and contextual information more effectively [37].This makes BiLSTMs particularly well-suited for tasks like sentiment analysis, machine translation, and time series prediction, where contextual information is crucial for accurate classification.In addition to replacing the LSTM with a BiLSTM, incorporating an attention mechanism into the model can further enhance its performance.Attention mechanisms allow the model to focus on the most relevant parts of the input sequence, dynamically assigning weights to different parts of the sequence based on their importance.This is particularly beneficial for imbalanced data classification, where the minority class samples are often overshadowed by the majority class samples [38].By selectively focusing on the minority class samples, the attention mechanism can help the model to better learn their characteristics and improve its classification accuracy for the minority class.The combination of a BiLSTM with an attention mechanism can provide a powerful and effective approach to handling imbalanced data classification tasks.The BiLSTM's ability to capture long-range dependencies and contextual information, coupled with the attention mechanism's ability to selectively focus on the most relevant parts of the input sequence, can lead to significant improvements in classification performance, particularly for the minority class.This paper introduces AttBiLFNet architecture, a novel network model that proficiently addresses the challenges of arrhythmia detection in ECG signals, particularly focusing on class imbalance.The proposed method effectively extracts and classifies arrhythmia patterns using a BiLSTM network with a CNN combined with an attention mechanism and Focal Loss.The performance of the proposed model has been comprehensively evaluated with existing approaches and has consistently outperformed them in terms of both accuracy and computational efficiency.Additionally, the proposed method has been compared with a hybrid approach that uses both advanced and traditional feature extraction methods by integrating the Univariate Feature Selection (UFS) method into the model.The UFS method identifies the most important features by evaluating the performance of each feature individually through classifiers [39].Combining these two methods is aimed to lead to more meaningful and effective feature selection.To the best of our knowledge, AttBiLFNet represents the first application of this particular combination of techniques in the context of arrhythmia detection.
The key contributions of this work are summarized as follows: • The development of a novel network architecture, AttBiLFNet, that effectively addresses the challenges of arrhythmia detection in the context of class imbalance of ECG signals.
• The compelling extraction and classification of arrhythmia patterns using a BiLSTM network with a CNN combined with an attention mechanism and the Focal Loss function.
• The proposed method is comprehensively evaluated in comparison to existing approaches, demonstrating superior performance in both accuracy and computational efficiency.
• The comparison of the proposed method with a hybrid approach that uses both advanced and traditional feature extraction methods by integrating the UFS method into the model.
• The first implementation of this customized combination of techniques in the field of arrhythmia detection.
The remainder of this paper is organized as follows: Section 2 details the experimental datasets, network architecture, and analysis of the methodologies used.Subsequently, Sections 3 and 4 provide a comprehensive comparison and evaluation of the proposed model's performance.

Dataset and data preparation
The MIT-BIH Arrhythmia Database (MITDB) is a publicly available collection of 48 half-hour excerpts of two-channel ambulatory ECG recordings from 47 subjects.The recordings were obtained from the BIH Arrhythmia Laboratory between 1975 and 1979.The database includes a wide variety of arrhythmias, including atrial fibrillation, atrial flutter, ventricular tachycardia, and premature ventricular contractions.The MITDB has been used extensively for the development and evaluation of arrhythmia detection algorithms.In this work, we selected five classes that are widely used in the literature [10]: Right Bundle Branch Block (RBBB): RBBB is a cardiac conduction disorder characterized by a delay in the transmission of electrical impulses through the right bundle branch (RBB) of the heart's His-Purkinje system.This delay results in a widening of the QRS complex on an ECG, indicating a prolonged activation of the right ventricle.While RBBB is often asymptomatic and benign, it may also be associated with various cardiovascular conditions and pulmonary diseases.Therefore, a thorough clinical evaluation is crucial to determine the underlying cause of RBBB and assess the overall cardiac health of individuals with this conduction abnormality.
Left Bundle Branch Block (LBBB): LBBB is a cardiac conduction disorder characterized by a prolonged or impeded electrical impulse along the left bundle branch, a crucial component of the heart's electrical conduction system.This abnormality often manifests on an ECG as a widened QRS complex, reflecting the delayed activation of the left ventricle.LBBB can arise from various underlying cardiac conditions, including myocardial infarction, cardiomyopathy, or structural heart disease.Clinical presentations of LBBB range from asymptomatic individuals to those experiencing symptoms such as heart failure, palpitations, or dizziness.Diagnosing and managing LBBB involve a comprehensive evaluation encompassing the patient's medical history, clinical symptoms, and additional cardiac testing to determine the underlying cause and assess overall cardiovascular health.Treatment strategies primarily focus on addressing the root cause while managing associated symptoms, emphasizing the importance of a multidisciplinary approach in the care of individuals with Left Bundle Branch Block.
Normal beats (N): Regular and rhythmic heart contractions, known as normal beats, play a crucial role in maintaining cardiovascular health.These physiological occurrences, characterized by the depolarization of the atria and ventricles, ensure an efficient blood-pumping mechanism throughout the circulatory system.Grasping the intricacies of N beats is paramount in the realm of cardiac electrophysiology, offering valuable insights for healthcare professionals in diagnosing and managing various cardiac conditions.Researchers in the field of cardiology delve into the nuances of N beats to comprehend the normal functioning of the heart, paving the way for advancements in medical science for the prevention and treatment of cardiovascular disorders.
Atrial premature beats (APBs): APBs, also known as premature atrial contractions (PACs), are a type of cardiac arrhythmia characterized by the origination of premature depolarization within the atria.These ectopic beats disrupt the heart's normal electrical rhythm, resulting in an early contraction of the atria before the expected heartbeat sequence.While often benign and asymptomatic, APBs can sometimes lead to palpitations, a fluttering sensation in the chest, or other mild symptoms.The identification and comprehension of APBs are crucial in clinical cardiology, as their presence may indicate an underlying cardiovascular condition.Diagnostic tools such as ECG play a crucial role in recognizing and assessing the frequency of APBs, assisting healthcare professionals in the comprehensive evaluation and management of individuals presenting with this cardiac arrhythmia.
Premature ventricular contraction (PVC): PVC is a prevalent cardiac arrhythmia characterized by untimely contractions originating from the ventricles, the heart's lower pumping chambers.These ectopic beats disrupt the regular heartbeat, potentially impairing the heart's ability to effectively pump blood.PVCs often manifest as palpitations and can be detected through ECG, which reveals abnormal QRS complexes.While occasional PVCs may be harmless, frequent or sustained occurrences may signal underlying cardiovascular problems and may warrant further evaluation and management.Enlightening the mechanisms and triggers of PVCs is essential for developing personalized interventions to address this prevalent cardiac arrhythmia and its potential implications for overall cardiovascular health.Univariate feature selection (UFS) is a statistical method widely used in machine learning and data analysis to identify and select the most informative features from a dataset.The primary aim of this technique is to improve the model performance and reduce the dimensionality by retaining only the most relevant variables.Univariate feature selection individually assesses the significance of each feature, independently of the others, making it particularly useful when dealing with high-dimensional datasets.The process involves evaluating the relationship between each feature and the target variable based on statistical metrics such as correlation, mutual information, or statistical tests like Analysis of Variance (ANOVA).Then, features with the highest scores or statistical significance are selected for further analysis or model training.One common formula used in UFS is the F-statistic for ANOVA.For a given feature, the F-statistic is calculated as the ratio of the variance between groups to the variance within groups.Mathematically, it is represented as: where the variance between groups measures the differences in means among various categories, and the variance within groups represents the variability within each category.A higher F-statistic indicates greater differences between group means and, therefore, a potentially more informative feature.Researchers and data scientists often set a threshold or use statistical tests to determine the significance of the F-statistic and select features accordingly.UFS provides a systematic approach to enhance model efficiency and interpretability by focusing on the most relevant features in a dataset [39,40].

Convolutional Neural Network (CNN) and bidirectional LSTM (BiLSTM)
Convolutional Neural Networks (CNNs) and Bidirectional Long Short-Term Memory (BiLSTM) networks are specialized architectures within the field of deep learning.CNNs excel, particularly in image recognition tasks.Fundamentally, they comprise convolutional and pooling layers.Convolutional layers amplify features within the input data while pooling layers diminish dimensionality while preserving crucial features.The convolution operation is frequently represented mathematically in (2): Here, the input is denoted by x and the kernel or filter by w.The feature map, y, is the result of applying the kernel to the input [36].
BiLSTMs are widely used in natural language processing tasks, providing the capability to interact with both past and future contexts of the input data.BiLSTMs can retain and process information by taking into account the context beyond the immediate input.A BiLSTM cell is typically formulated as: In these equations,  represents the input, ℎ is the output of the cell,  ,  ,  and  denote input, forget, output, and memory gates, respectively. and  terms indicate weights and biases,  represents the sigmoid function, tanh is the hyperbolic tangent function, and ⊙ signifies element-wise multiplication [41].

Attention Mechanism
The attention mechanism employs dynamic weighting to evaluate the significance of individual elements within an input sequence.These weights are adjusted adaptively based on the relative importance of each element, enabling the model to enhance its learning and focusing capability.The attention mechanism has demonstrated effectiveness in tasks involving sequential data, particularly in the fields of natural language processing (NLP) and machine translation.Mathematically, the attention mechanism can be expressed as follows: Considering a data input as a sequence  = { ,  , … ,  } and hidden states  = {ℎ , ℎ , … , ℎ }, where  represents the length of the input sequence.
The attention weights, denoted as  = { ,  , … ,  }, are typically calculated using a network or a set of learnable parameters.These attention weights are often normalized using the softmax function to ensure the sum of the total weight to 1: Here, ℎ is usually a query vector, and  is measured using a scoring function, which could involve various methods such as dot product, scalar product, or another similarity metric.
Finally, a weighted combination is formed using these weights: Here,  symbolizes the context vector, which is often utilized in the remainder of the model.
This formulation constitutes the fundamental concept of the attention mechanism, enabling the model to focus on specific segments and emphasize essential information, particularly beneficial when dealing with lengthy input sequences [42].

Focal Loss
Focal Loss is a specialized loss function designed primarily for classification problems, particularly effective in addressing issues related to class imbalance.This function finds significant application in tasks such as object recognition.To comprehend Focal Loss, it is beneficial to first recall the Cross-Entropy Loss, which is commonly utilized for multi-class classification problems.
The Cross-Entropy Loss, expressed by the following formula, serves as a foundational understanding: Here: •  denotes the probability vector predicted by the model.
•  represents the one-hot encoded vector corresponding to the actual class.
•  signifies the  − ℎ element of the true class.
•  represents the  − ℎ element of the predicted class.
Focal Loss stands as an improved version of the Cross-Entropy Loss, specifically tailored to address the challenges posed by class imbalance more effectively.The formula for Focal Loss is articulated as follows: Here: •  is a hyperparameter, often set to 2.
• Other variables remain consistent with the Cross-Entropy Loss.
Notably, Focal Loss incorporates the term 1 −    to facilitate a stronger focus on rare classes.
This term ensures that correctly classified instances result in less pronounced updates to the model, effectively mitigating the impact of class imbalance.In this formula,   represents the predicted probability by the classification model,   denotes the actual class, and  signifies the focus parameter [32].

AttBiLFNet
AttBiLFNet is a hybrid network architecture that effectively addresses the challenges of arrhythmia detection in the context of imbalanced ECG signal datasets.The proposed method successfully extracts and classifies arrhythmia patterns by utilizing a BiLSTM network with a CNN, combined with an attention mechanism and the Focal Loss function.Furthermore, the proposed method has been compared with a hybrid approach that employs both advanced and traditional feature extraction methodologies by integrating the UFS algorithm into the model.In this comparison, AttBiLFNet_1, the version without UFS, and AttBiLFNet_2, the version with UFS, were evaluated.A detailed illustration of the proposed AttBiLFNet architecture is provided in Figure 2.

Results and Discussions
This paper introduces a novel network architecture, called AttBiLFNet, for challenging arrhythmia detection in ECG signals containing class imbalance.The proposed AttBiLFNet architecture effectively extracts and classifies arrhythmia patterns utilizing the BiLSTM network with a CNN combined with the attention mechanism and the Focal Loss.The constructed models were tested on a computer equipped with an Intel Xeon E5-2630 2.3 GHz CPU and 12 GB RAM.Additionally, the proposed method has been compared with a hybrid approach that uses both advanced and traditional feature extraction methods by integrating the UFS technique with the proposed AttBiLFNet architecture.

Evaluation metrics
The datasets were divided into training and test sets using 10-fold cross-validation.This process was implemented in each proposed model to evaluate its performance.The average experimental results were then calculated for accuracy, sensitivity, specificity, Kappa score, and Macro F1 score, as defined in Eq. ( 14) -Eq.( 18 Accuracy is a fundamental metric for evaluating classification models, measuring the proportion of correctly classified instances.It encompasses both true positives (TP), instances correctly predicted as positive, and true negatives (TN), instances correctly predicted as negative.However, accuracy can be misleading in situations where the dataset is imbalanced, with one class significantly more prevalent than the others.In such cases, sensitivity (recall) and specificity become more relevant metrics.
Sensitivity, also known as recall, evaluates the model's ability to correctly identify actual positive instances.It is calculated as the ratio of TP to the total number of actual positive instances (TP + FN).Specificity, on the other hand, evaluates the model's capability to correctly identify actual negative instances.It is calculated as the ratio of TN to the total number of actual negative instances (TN + FP).The kappa score, a more sophisticated metric, measures the agreement between predicted and actual classifications, accounting for the agreement that could have occurred by chance.The macro F1 score aims to balance precision and recall on a per-class basis.It is calculated by independently calculating the F1 score for each class and then taking the unweighted average (macro-average) across all classes.The precision measures the proportion of correct positive predictions (TP / (TP + FP)), while recall assesses the proportion of actual positive instances that are correctly identified (TP / (TP + FN)).
These equations collectively provide a comprehensive evaluation framework for classification models, considering their ability to accurately classify instances, handle class imbalance, and measure the agreement between predicted and actual classifications.The results obtained for each metric allow for a comparison of the effectiveness of the different models studied in this paper.Additionally, it is crucial to account for variations in outcomes across multiple executions due to the stochastic nature of neural network models.Executing the model ten times and averaging the results for each metric ensures a more robust and dependable assessment of its performance.

Results
This work employs sensitivity, precision, accuracy, macro F1 (MF1), and Cohen's Kappa coefficient (K) as performance metrics.The proposed model's performance was evaluated using 10fold cross-validation.The detailed results of these experiments are listed in Table 2.

Method
Sensitivity (% ± SD) Precision (% ± SD) Accuracy (% ± SD) MF1 (% ± SD) K (% ± SD) AttBiLFNet_1 98.The performance metrics for each arrhythmia class are provided in Tables 3 and Table 4.The highest performance was achieved in the LBBB and RBBB classes, while the lowest performance was obtained in the APB class.Figure 3 illustrates a performance comparison of different components in three different scenarios for the APB class.In the first scenario, LSTM was preferred over BiLSTM.In the second scenario, Categorical Cross Entropy was used instead of Focal Loss.In the third scenario, the Attention Mechanism was removed from the model.All scenarios were tested, and their performances were compared to the proposed model.The proposed model achieved the highest performance, followed by the method used in the first scenario.The worst performance occurred in the third scenario, where Attention Mechanism was not used.Table 5 presents a performance comparison of the proposed AttBiLFNet model with the other state-of-the-art ECG studies.The highest results are highlighted in bold for easy identification.The field of arrhythmia classification has witnessed a surge in the development of novel methodologies, each aiming to achieve superior performance metrics.Notable contributions include the works of [1,43,44], all of which have surpassed a remarkable 99% accuracy threshold.A common thread among these algorithms is their adherence to the end-to-end paradigm, which effectively eliminates the need for a separate feature extraction step.This characteristic highlights the efficacy of the end-to-end methodology in attaining high precision across a diverse spectrum of arrhythmias.In contrast, [45] embarked on a distinct approach, employing an autoencoder (ACN) to extract features from ECG signals, followed by classification using a Support Vector Machine (SVM) classifier.This strategy resulted in a commendable accuracy of 98.84%.Additionally, researchers have explored alternative avenues for feature extraction from input signals, utilizing a variety of techniques.[22], for instance, introduced a discrete wavelet transform to enhance the performance of BiLSTM networks.This innovative approach involved fusing wavelet coefficient features with ECG signal features, as mapped by Bidirectional LSTM, culminating in an impressive accuracy of 99.39% in arrhythmia classification.Building upon this success, [46] incorporated a convolutional ACN to extract encoded ECG features, subsequently inputting them into an LSTM classifier for automated arrhythmia detection.This approach yielded accuracy rates of 99.11% for encoded features and 99.23% for raw ECG data.Diverging from the prevailing end-to-end paradigm, [47] opted for wavelet features, achieving a commendable accuracy of 97.41%.This diversity in approaches underscores the dynamic landscape of methodologies employed in the pursuit of accurate arrhythmia classification.Moreover, [10] proposes a novel deep learning-based approach for arrhythmia detection from ECG signals.Their approach, termed DeepArr, utilizes a 1D-CNN and a BiLSTM layer.The 1D-CNN extracts local spatiotemporal features from the ECG signal, while the BiLSTM captures the contextual features of arrhythmia from the extracted features.Their proposed method achieves an accuracy of 99.46%, a specificity of 99.57%, a sensitivity of 97.01%, a precision of 98.26%, and an F1-score of 97.63%.Additionally, they demonstrate the effectiveness of employing CNN and BiLSTM in tandem for arrhythmia detection.As can be discerned from Table 5, AttBiLFNet exhibits superior performance when compared to other works.The DeepArr approach is the closest model to ours, and with this method, as shown in Table 6, our approach demonstrably outperforms DeepArr by approximately 3% for the APB class, particularly when analyzing the performance of arrhythmia classes.This highlights the effectiveness of our model in handling class imbalance.Furthermore, the MF1 score of our proposed method surpasses that of all other studies in the table by approximately 1%.Despite AttBiLFNet_1 demonstrating the highest performance, our experiments reveal that the training time for each epoch of AttBiLFNet_2 is approximately 40% faster than that of AttBiLFNet_1.Consequently, while there is a slight decrease in performance when utilizing UFS, it facilitates a more efficient process.In this work, a novel arrhythmia detection method called AttBiLFNet is proposed.This method is designed as a neural network that includes attention mechanisms, BiLSTM, CNN layers, and focal loss.The attention mechanism enables the model to focus on specific features and highlight important information, enabling it to focus more precisely on the attributes that are critical for arrhythmia detection.The BiLSTM layer is employed to more effectively model changes over time in arrhythmia detection, as these changes can play an important role in the diagnostic process.The CNN component is used to recognize local features and distinguish particular patterns, which has provided us to more accurately address the complex and localized features of arrhythmias.Besides, focal loss makes the learning process more balanced by enabling the model to better handle examples in rare classes.Through the combination of these layers, AttBiLFNet was able to perform more precisely and comprehensively in arrhythmia detection.

Conclusion
In this paper, a novel hybrid network architecture was proposed for arrhythmia detection, which is insensitive to imbalanced class distributions.This innovative hybrid model effectively captures and classifies arrhythmia patterns in the ECG signal data by employing a combination of a BiLSTM network, a CNN, an attention mechanism, and the Focal Loss function.This multi-hybrid combination improves the proposed model's ability to distinguish subtle patterns in imbalanced datasets, enabling higher accuracy in arrhythmia detection while sustaining computational efficiency.Through a comprehensive evaluation and comparative performance analysis with the existing approaches, the proposed model demonstrates superior performance, proving to be an advanced solution to overcome the challenges posed by imbalanced ECG signal datasets.In addition to comparing AttBiLFNet with established methods, the paper explores a hybrid approach that integrates both advanced techniques and traditional feature extraction methods for arrhythmia detection.This comparative analysis provides a holistic view of the proposed method's efficacy, demonstrating its advantages over hybrid approaches and reaffirming its promise as a cutting-edge solution for addressing class imbalance in arrhythmia detection.Hence, AttBiLFNet emerges as a promising and robust approach, offering advancements in both accuracy and computational efficiency, thereby contributing to the evolution of arrhythmia detection methodologies.Future research will focus on developing various strategies to further improve the performance of AttBiLFNet.In this context, more effective methods will be investigated to address the issue of data imbalance, and the model's feature extraction capabilities will be enhanced by integrating with other advanced techniques.Also, some new techniques are intended to be developed to optimize real-time performance, notably on resource-constrained devices.

Use of AI tools declaration
The authors declare that they have not used Artificial Intelligence (AI) tools in the creation of this article.

Figure 1 .
Figure 1.The 12-lead ECG system.a) The spatial arrangement of the 10 electrodes employed in the 12-lead ECG system.b) Electrodes on human skin capture the electrical potential differences, and ECG signals from 12 leads depict the heart's electrical activity from various angles [3].

Figure 3 .
Figure 3. Comparing the performance of various versions of the proposed model with different component combinations

Table 1 .
Table 1 provides the beat counts for each class of arrhythmia waveform; The number of heartbeats and classes for the MIT-BIH dataset.

Table 3 .
Performance metrics achieved on the five classes for AttBiLFNet_1.

Table 4 .
Performance metrics achieved on the five classes for AttBiLFNet_2.

Table 5 .
Performance comparison of the proposed AttBiLFNet model with other state-of-the-art ECG studies on the MIT-BIH database.