ArrythML-II: An Optimized TinyML Framework for ECG Arrhythmia Detection and Multi-Class Beat Classification on Wearable Devices
Organizations: International Institute of Information Technology, Bangalore, India
Abstract
This paper presents ArrythML-II, an optimized TinyML framework for on-device ECG arrhythmia detection and multi-class beat classification on wearable platforms. A systematic hyperparameter optimization framework is developed to identify compact autoencoder architectures for binary ECG arrhythmia detection. A custom scoring mechanism jointly considers detection performance, reconstruction-error thresholds, and model size to guide architecture selection. The framework is further extended to six-class ECG beat classification using a lightweight classifier derived from the optimized autoencoder architecture. Both models are INT8 quantized and deployed using TensorFlow Lite Micro on a custom-developed, battery-operated, single-lead ECG device based on the PSoC6 microcontroller. The deployed autoencoder and classifier have model sizes of approximately 44KB and 22KB, respectively, with end-to-end processing times of 5.1ms and 4.7ms per ECG segment. Model inference accounts for 3.95ms and 1.38~ms of these processing times, respectively. In the refined arrhythmia detection evaluation using the MIT-BIH Arrhythmia Database, the autoencoder achieved an accuracy of 84.76%, precision of 82.68%, and recall of 77.99%. The multi-class classifier achieved 82.29% accuracy, weighted precision of 90.18%, and weighted recall of 82.29%. Beyond offline model evaluation, the wearable platform is validated using preloaded ECG segments, live ECG signals, and an ESP32-S3-based ECG emulator that replays annotated MIT-BIH recordings as analog waveforms. The results demonstrate the feasibility of integrating optimized TinyML models into wearable platforms for real-time ECG analysis.
Figures & tables
| ID | Config | Layers | Percentile | Accuracy | Recall | Size (KB) | Score |
| 1 | [60, 30] | 2 | 98 | 0.8641 | 0.6502 | 44.02 | 0.8111 |
| 2 | [60] | 1 | 98 | 0.8493 | 0.5883 | 39.05 | 0.8091 |
| 3 | [90, 60] | 2 | 98 | 0.8752 | 0.6678 | 68.98 | 0.8061 |
| 4 | [60, 30] | 2 | 95 | 0.8708 | 0.7014 | 44.02 | 0.8046 |
| 5 | [60] | 1 | 95 | 0.8696 | 0.7085 | 39.05 | 0.8040 |
| 6 | [120] | 1 | 98 | 0.8745 | 0.6678 | 74.41 | 0.7990 |
| Exp. | Evaluation | Model | Variant | Accuracy (%) | Precision (%) | Recall (%) | F1-Score (%) | Size (kB) |
| 1 | Hyperparameter-tuned models | DNN-based | Quantized | 76.45 | 63.70 | 77.58 | 69.96 | 44.0 |
| CNN-based | Quantized | 77.97 | 64.91 | 82.04 | 72.48 | 18.0 | ||
| 2 | Refined evaluation | DNN-based | Quantized | 84.76 | 82.68 | 77.99 | 80.27 | – |
| CNN-based | Quantized | 86.44 | 83.19 | 82.58 | 82.88 | – | ||
| 3 | Binary (mapped) | Multi-class | Quantized | 90.90 | 82.70 | 93.70 | 87.85 | 22.84 |
| 4 | Multi-class classifier | Multi-class | Quantized | 82.29 | 90.18 | 82.29 | 83.11 | 22.84 |
| Reference MIT–BIH Annotations | Segmentation and Inference on wearable | Segmentation and Inference on PC-side | ||||||||
| Record | R-Peak | Anno. | Segment | Re.Err. | Cycles | Time (ms) | Class | Segment | Re.Err. | Class |
| 100 | 18 | + | (–,–) | – | – | – | – | (–,–) | – | – |
| 100 | 77 | N | (–,–) | – | – | – | – | (–,–) | – | – |
| 100 | 370 | N | (77,370) | 0.0531 | 882369 | 8.8237 | Normal | (77,370) | 0.0529 | Normal |
| 100 | 662 | N | (370,663) | 0.0442 | 882018 | 8.8202 | Normal | (370,663) | 0.0441 | Normal |
| 100 | 946 | N | (663,947) | 0.0630 | 882170 | 8.8217 | Normal | (663,947) | 0.0632 | Normal |
| Record | Representative | MIT-BIH | Autoencoder | Multiclass | Processing | Average Inference |
| Segment | Annotation | Output | Output | Time (ms) | Cycles (Time in ms) | |
| 100 | (77,370) | N | Normal | N | 4.71 | 138064 (1.38) |
| 107 | (268,565) | / | Abnormal | / | 4.71 | 137976 (1.38) |
| 214 | (347,661) | L | Abnormal | L | 4.71 | 138182 (1.38) |
| 232 | (1001,1660) | A | Abnormal | A | 4.71 | 138196 (1.38) |
| 233 | (320,750) | V | Abnormal | V | 4.71 | 138031 (1.38) |
| Record | Segments | Reconstruction-Error | Mean Reconstruction | Autoencoder | Average Processing | Average Inference |
| Processed | Range | Error | Output | Time (ms) | Cycles / (ms) | |
| 100 | 5 | 0.0352–0.0400 | 0.0381 | Normal | 5.0575 | 394680 (3.95) |
| 107 | 6 | 0.1247–0.2295 | 0.1813 | Abnormal | 5.0575 | 394173 (3.94) |
| 207 | 4 | 0.1269–0.1754 | 0.1420 | Abnormal | 5.0575 | 394748 (3.95) |
| 118 | 5 | 0.0821–0.0940 | 0.0884 | Abnormal | 5.0576 | 394694 (3.95) |
| 106 | 4 | 0.0957–0.1443 | 0.1122 | Abnormal | 5.0577 | 395056 (3.95) |
Electrocardiogram Classification
Electrocardiogram classification uses machine learning to identify heart rhythms and cardiac conditions from ECG waveforms for screening, diagnosis, and monitoring.
See all 122 papers