ECG Arrhythmia Detection (CNN + BiLSTM + Attention)

Classifies a single ECG heartbeat (187 samples at 125 Hz, scaled 0–1) into the five AAMI classes: Normal (N), Supraventricular (S), Ventricular (V), Fusion (F) and Unknown (Q).

Files

File Description
best_model.pth PyTorch state_dict of ECG_CNN_LSTM_Deep (2.65 M parameters)
scaler.pkl scikit-learn 1.6.1 StandardScaler fitted on the training beats

Test results (MIT-BIH heartbeat test split, 21,892 beats)

Accuracy Macro F1 Weighted F1
99.00% 94.0% 99.0%

Usage

import joblib, torch
from huggingface_hub import hf_hub_download
from model_definition import ECG_CNN_LSTM_Deep   # from the GitHub repo (backend/)

repo = "nikhilkumar905/ECG-Arrhythmia-Detection"
model = ECG_CNN_LSTM_Deep(num_classes=5)
model.load_state_dict(torch.load(hf_hub_download(repo, "best_model.pth"), map_location="cpu"))
model.eval()
scaler = joblib.load(hf_hub_download(repo, "scaler.pkl"))

# beats: NumPy array of shape (N, 187)
x = torch.tensor(scaler.transform(beats), dtype=torch.float32).unsqueeze(1)
pred = model(x).argmax(1)   # 0=N, 1=S, 2=V, 3=F, 4=Q

Limitations

The Kaggle split separates heartbeats, not patients, so results on new patients will be lower. Single lead, single beat, no rhythm context. For research and education only, not a medical device.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support