Skip to content

Sakeeb91/ecg-arrhythmia-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ECG Arrhythmia Classification System

A production-ready machine learning system for automated detection and classification of cardiac arrhythmias from raw ECG signals. Built using the MIT-BIH Arrhythmia Database with both classical ML and deep learning approaches.

Overview

Cardiovascular diseases are the leading cause of death globally. This project implements an automated ECG analysis pipeline that enables early detection of arrhythmias for applications in remote patient monitoring, wearable devices, and clinical decision support systems.

Features

  • End-to-end signal processing pipeline (filtering, baseline correction, R-peak detection)
  • AAMI-standard 5-class arrhythmia classification (N, S, V, F, Q)
  • Multiple model architectures (Random Forest, XGBoost, 1D CNN, LSTM with Attention)
  • Comprehensive evaluation metrics with clinical relevance
  • Model explainability using SHAP and Grad-CAM
  • Production-ready inference class

Classification Scheme (AAMI Standard)

Class Label Original Annotations
N Normal N, L, R, e, j
S Supraventricular A, a, J, S
V Ventricular V, E
F Fusion F
Q Unknown/Paced /, f, Q

Project Structure

ecg-arrhythmia-classification/
├── data/                      # Dataset directory (not tracked)
├── models/                    # Saved model weights
├── notebooks/
│   └── EDA.ipynb             # Exploratory data analysis
├── src/
│   ├── ecg_preprocessing.py  # Signal processing pipeline
│   ├── feature_extraction.py # Hand-crafted feature extraction
│   ├── models.py             # Model architectures
│   ├── train.py              # Training loop
│   ├── evaluate.py           # Evaluation and visualization
│   └── inference.py          # Production inference class
├── docs/
│   └── IMPLEMENTATION_PLAN.md
├── requirements.txt
└── README.md

Quick Start

# Clone the repository
git clone https://github.com/Sakeeb91/ecg-arrhythmia-classification.git
cd ecg-arrhythmia-classification

# Install dependencies
pip install -r requirements.txt

# Download the MIT-BIH dataset
python scripts/download_data.py

# Train models
python src/train.py

# Evaluate and generate visualizations
python src/evaluate.py

# Run inference demo
python scripts/demo.py

Dataset

MIT-BIH Arrhythmia Database (PhysioNet)

  • 48 half-hour two-lead ECG recordings from 47 patients
  • Sampling rate: 360 Hz
  • Approximately 110,000 annotated heartbeats
  • Inter-patient split for realistic evaluation

Technical Pipeline

Raw ECG → Bandpass Filter (0.5-40Hz) → Baseline Wander Removal →
R-Peak Detection → Beat Segmentation → Normalization → Model Input

Expected Results

Model Accuracy Weighted F1
Classical ML (XGBoost) 95-97% 0.93-0.95
1D CNN 97-99% 0.96-0.98
Inter-patient (realistic) 90-95% 0.88-0.93

Requirements

  • Python 3.8+
  • PyTorch 1.9+
  • See requirements.txt for full dependencies

License

MIT License

References

  • Moody GB, Mark RG. The impact of the MIT-BIH Arrhythmia Database. IEEE Eng Med Biol Mag. 2001
  • AAMI. Recommended Practice for Testing and Reporting Performance Results of Cardiac Rhythm and ST Segment Measurement Algorithms. ANSI/AAMI EC57:2012

About

Production-ready ML system for automated ECG arrhythmia classification using MIT-BIH database

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages