case study · ai / biomedical

ecg arrhythmia classification.

Classifying individual heartbeats from single-lead ECG signals — evaluated on 22 completely unseen patients, with honest per-class metrics.

AI / BiomedicalCompleted
PythonScikit-learnStreamlitMIT-BIHwfdb

overview

ECG Arrhythmia Classification takes a raw single-lead ECG signal and classifies each heartbeat into four AAMI classes — Normal (N), Supraventricular premature (S), Ventricular premature (V), and Fusion (F) — using the MIT-BIH Arrhythmia Database. A 50-tree Random Forest over 57 features reaches 93.3% accuracy and Macro F1 = 0.688 on 22 unseen DS2 test patients. You can run the exact DSP & inference pipeline directly in the browser inside BioVanta ECG Analysis Studio, or install the Android APK (v2.0.0).

problem

Heartbeat classification is easy to get wrong in a flattering way: if beats from the same patient appear in both training and test splits, a classifier memorizes patient morphology rather than arrhythmia physiology. The honest evaluation is inter-patient: train on DS1 (22 patients), test on DS2 (22 completely separate patients), and report both overall accuracy and minority-class F1.

data

  • dataset — MIT-BIH Arrhythmia Database, single-lead MLII ECG (360 Hz)
  • split — de Chazal inter-patient split: 22 patients in DS1 train, 22 patients in DS2 test; zero patient overlap
  • test beats — N: 44,167 · S: 1,825 · V: 3,183 · F: 383 (49,558 raw-matched beats)

Normal beats outnumber supraventricular beats roughly 24 to 1 in DS2 — making macro F1 essential alongside accuracy.

method

Raw single-lead signals go through linear resampling to 360 Hz, zero-phase 3rd-order Butterworth bandpass filtering (0.5–40 Hz), Pan–Tompkins R-peak detection (99.7% sensitivity), 200-sample median-centered beat segmentation, and 57 frozen features fed to a 50-tree Random Forest with decision weights [1.0, 2.0, 1.0, 0.0].

results

On the 22 unseen DS2 test patients: Accuracy 93.3% (0.933) and Macro F1 = 0.688 across N, S, and V. Accuracy alone is lifted by the dominant Normal class; macro F1 surfaces the exact trade-off on minority rhythms.

N — Normal · F10.965 · 44,167 beats
S — Supraventricular · F10.177 · 1,825 beats
V — Ventricular · F10.923 · 3,183 beats
F — Fusion · F1not predicted (weight 0) · 383 beats

Per-class S detail: precision 0.201, recall 0.158, F1 0.177. Fusion beats have weight 0 to avoid thousands of false positives.

limitations

The S class remains unreliable (F1 0.177) because supraventricular beats resemble normal QRS morphology and differ mainly in subtle timing; the F class is intentionally disabled (weight 0). Evaluation covers a single database (MIT-BIH lead MLII) and is strictly educational — not clinically validated.

Educational project only — not clinically validated and not intended for diagnosis or medical decision-making.

links

← Back to projects