Home 0%
← Projects

ECG Arrhythmia Classification

A controlled comparison of evaluation protocols for ECG beat classification, using 100,705 annotated beats from the MIT-BIH Arrhythmia Database. Holding the model and the features constant and varying only the train/test partition moves macro F1 from 0.904 to 0.446.

I built this as practice in scraping and analysing public data, so it should be read as a skills exercise. The findings summarise what is already present in the source dataset.

Source
MIT-BIH Arrhythmia Database, PhysioNet
Scale
100,705 annotated beats from 44 records
Tools
Python, scikit-learn, wfdb
Date
June 2026
01

Question

Published accuracy figures for arrhythmia classification frequently exceed 98%, a level that would imply the problem is effectively solved. Those figures are usually produced by partitioning beats at random, which allows beats from the same patient to appear in both the training and the test set.

I therefore trained one random forest twice on identical data and identical features, varying only the partition, so that any difference in reported performance is attributable to the evaluation protocol alone.

02

Results

PartitionAccuracyMacro F1
Random, with beats shuffled and patients on both sides98.78%0.904
Inter-patient, where DS1 trains and DS2 tests90.39%0.446
03

Interpretation

04

Figures

Confusion matrix, random split.
Confusion matrix, random split.
Confusion matrix, inter-patient split.
Confusion matrix, inter-patient split.
The two splits side by side.
The two splits side by side.
05

Method and limitations

Beats are windowed 90 samples before and 110 after each annotated R-peak, normalised per beat, and paired with two RR-interval features so that the model can observe whether a beat arrived early. Labels follow the five AAMI classes, and the four paced records (102, 104, 107 and 217) are excluded under AAMI recommended practice. The DS1/DS2 division follows de Chazal et al. (2004) so that results remain comparable across papers. A single random forest with fixed hyperparameters is used throughout, so the absolute figures set no ceiling on achievable performance, and the comparison is between evaluation protocols, saying nothing about which model performs best.