Skip to content

About

Deep learning project for ECG arrhythmia classification using a hybrid GRU–Transformer architecture.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

HEART 🫀

Hybrid ECG Arrhythmia Recognition using GRU–Transformer Architecture

HEART is a deep learning project developed for automated cardiac arrhythmia classification from Electrocardiogram (ECG) signals.

The project introduces a dual-branch architecture that combines Gated Recurrent Units (GRUs) for rhythm and temporal modeling with a Transformer branch for ECG morphology analysis. The two branches interact through Residual-Gated Cross-Attention (RGCA) to combine complementary ECG representations.

Project Objectives

  • Preprocess ECG signals from multiple datasets
  • Construct a comprehensive ECG feature representation
  • Design a dual-branch GRU–Transformer architecture
  • Integrate Residual-Gated Cross-Attention (RGCA)
  • Evaluate performance under inter-patient, intra-patient, and transfer learning settings
  • Assess model generalization across different ECG datasets

Datasets

Three complementary ECG datasets were used throughout the project:

Dataset Purpose
MIT-BIH Arrhythmia Database Main benchmark dataset
MIT-BIH Supraventricular Arrhythmia Database (SVDB) Improve S-class representation
Icentia11k Generalization and transfer learning

Experimental Studies

HEART was evaluated through three complementary experimental studies designed to assess benchmark performance, large-scale generalization, and cross-dataset transferability.

Study 1 — MIT-BIH Benchmark Evaluation

The first study evaluated HEART on the MIT-BIH Arrhythmia Database using both inter-patient and intra-patient evaluation protocols.

Inter-Patient Evaluation

Metric Result
Accuracy 98.50%
Macro-F1 93.70%
MCC 91.99%
S-Class Sensitivity 81.13%
V-Class Sensitivity 93.10%

Benchmark Comparison

HEART Inter-Patient Benchmark

HEART achieved strong inter-patient performance compared with previous ECG arrhythmia classification studies, particularly in overall accuracy and S- and V-class recall.

Intra-Patient Evaluation

Metric Result
Accuracy 99.68%
Macro-F1 99.68%
MCC 99.52%
S-Class Sensitivity 99.45%
V-Class Sensitivity 99.82%

The inter-patient protocol provides a more realistic evaluation by testing the model on patients who were not included in the training set.


Study 2 — Icentia11k Large-Scale Evaluation

The second study evaluated the same HEART architecture on the large-scale Icentia11k dataset to assess its ability to generalize to a larger and more diverse patient population.

Metric Result
Accuracy 91.19%
Macro-F1 90.24%
MCC 83.98%

The results demonstrate that HEART maintains strong classification performance when applied to a substantially larger ECG dataset.


Study 3 — Cross-Dataset Transfer Learning

The third study evaluated HEART's ability to transfer learned ECG representations across different datasets.

The model was first pre-trained on Icentia11k, then fine-tuned on MIT-BIH DS1, and finally evaluated on the unseen MIT-BIH DS2 patient set.

Metric Result
Accuracy 98.18%
Macro-F1 92.61%
MCC 90.69%

Per-Class Performance

Class Precision Recall F1
Normal (N) 99.23% 98.82% 99.02%
Supraventricular (S) 77.99% 87.42% 82.43%
Ventricular (V) 97.03% 95.71% 96.37%

Transfer Learning Comparison

HEART Transfer Learning Results

Compared with Study 1, cross-dataset transfer learning increased S-class recall from 81.13% to 87.42% and V-class recall from 93.10% to 95.71%, while maintaining strong performance for Normal beats.

The Supraventricular class remained the most sensitive to cross-dataset domain shift, particularly in precision, showing that minority-class decision boundaries require greater adaptation across ECG datasets.

Model Architecture

HEART Architecture

The HEART pipeline consists of ECG signal preprocessing, RR-interval adaptive beat segmentation, feature extraction, and a hybrid GRU–Transformer architecture.

The model processes a 360-dimensional feature vector through two complementary branches:

  • GRU Branch: captures temporal and rhythm-related dependencies.
  • Transformer Branch: captures ECG morphology using attention mechanisms.
  • Residual-Gated Cross-Attention (RGCA): enables information exchange between the GRU and Transformer representations.
  • Classification Head: classifies ECG beats into Normal (N), Supraventricular (S), and Ventricular (V) classes.

Key Outcome

Across three complementary experimental studies, HEART demonstrated strong ECG arrhythmia classification performance under different evaluation settings.

The model achieved 98.50% accuracy and 93.70% Macro-F1 under the MIT-BIH inter-patient protocol and 99.68% accuracy and 99.68% Macro-F1 under the intra-patient protocol.

On the large-scale Icentia11k dataset, HEART achieved 91.19% accuracy and 90.24% Macro-F1, demonstrating its ability to maintain strong classification performance on a substantially larger ECG dataset.

The cross-dataset transfer learning study further demonstrated that HEART could retain useful representations across different ECG domains. After pre-training on Icentia11k and fine-tuning on MIT-BIH, the model achieved 98.18% accuracy, 92.61% Macro-F1, and 90.69% MCC on unseen MIT-BIH patients.

Project Type

Graduation Project
Computer Science
King Saud University
2026

About This Repository

This repository serves as a portfolio showcase of the HEART graduation project.

Selected architecture diagrams and experimental results are provided to demonstrate the project's methodology, model design, and evaluation, while the complete source code is kept private.

About

Deep learning project for ECG arrhythmia classification using a hybrid GRU–Transformer architecture.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors