Automated Identification of Heart Arrhythmias through HRV Analysis and Machine Learning


  • S. K. Lawal Department of Biomedical Engineering, Faculty of Engineering and Technology, University of Ilorin, Ilorin, Nigeria.
  • I. O. Muniru
  • S. A. Yahaya
  • M. O. Ibitoye University of Ilorin


Cardiovascular disorders; Arrhythmia; ECG; Heart Rate Variability; Diagnosis


Sudden cardiac death and arrhythmia are responsible for about 15-20% of cardiovascular disease incidences. Conventionally, the prediction and diagnosis of cardiovascular disorders (CVDs) have been mainly through the evaluation of ECG patterns by cardiologists. To improve the accuracy of and automate this process, and facilitate early detection, Heart Rate Variability (HRV) analysis has been promoted as a diagnostic and predictive tool for CVDs. In the present study, a machine learning model capable of detecting the presence of arrhythmia, using HRV indices obtained from ECG signals was built. Unlike similar works in the literature, this study deployed the developed model on Raspberry Pi with Streamlit software. Two ECG datasets from the Physionet database, one with arrhythmia patients (48 half-hour recordings) and another with healthy individuals (18 24-hour recordings), were employed. An ensemble of seven different machine learning models was used on the two sets of datasets to classify ECG recordings into Arrhythmia and Normal Sinus Rhythm (NSR). The best models were able to predict the presence of Arrhythmia in a 3-minute recording with an accuracy of 95.96%, and in a 10-minute recording with an accuracy of 96.20%. These performance measures were calculated using test dataset. The Random Forest models also had the highest precision, AUC, (Area under the Curve) recall, and F1 scores compared to the other models tested. The highest performing model (i.e., Random Forest Model) was then deployed onto a Raspberry Pi with Streamlit as the software interface for usability. This was done to facilitate a smooth user experience for faster and seamless diagnoses for cardiologists.


Albaladejo-González, M.; Ruipérez-Valiente, J. A. and Gómez Mármol, F. (2023). Evaluating different configurations of machine learning models and their transfer learning capabilities for stress detection using heart rate. Journal of Ambient Intelligence and Humanized Computing, 14 (8): 11011-11021.

Ali, N.; Neagu, D. and Trundle, P. (2019). Evaluation of k-nearest neighbour classifier performance for heterogeneous data sets. SN Applied Sciences, 1 (12): 1559.

Chuduc, H.; Nguyenphan, K. and Nguyenviet, D. (2013). A Review of Heart Rate Variability and its Applications. APCBEE Procedia, 7: 80-85.

Connell, P. S.; Price, J. F.; Rusin, C. G.; Howard, T. S.; Spinner, J. A.; Valdes, S. O.; Pham, T. D. N.; Miyake, C. Y. and Kim, J. J. (2023). Decreased Heart Rate Variability in Children with Acute Decompensated Heart Failure is Associated with Poor Outcomes. Pediatric Cardiology, 10.1007/s00246-023-03279-7.

Education, I. C. (2020). Supervised learning. IBM. Available online: com/cloud/learn/supervisedlearning (accessed on 23 December 2021).

El Naqa, I. and Murphy, M. J. 2015. What Is Machine Learning? In: El Naqa, I., Li, R. & Murphy, M. J. (ed.)^(eds.) Machine Learning in Radiation Oncology: Theory and Applications. Cham: Springer International Publishing.

Fletcher, G. and Rea, T. 2008. Sudden Cardiac Arrest. In: Heggenhougen, H. K. (ed.)^(eds.) International Encyclopedia of Public Health. Oxford: Academic Press.

Goldberger, A. L.; Amaral, L. A.; Glass, L.; Hausdorff, J. M.; Ivanov, P. C.; Mark, R. G.; Mietus, J. E.; Moody, G. B.; Peng, C.-K. and Stanley, H. E. (2000). PhysioBank, PhysioToolkit, and PhysioNet: components of a new research resource for complex physiologic signals. Circulation, 101 (23): e215-e220.

Haines, D. E.; Beheiry, S.; Akar, J. G.; Baker, J. L.; Beinborn, D.; Beshai, J. F.; Brysiewicz, N.; Chiu-Man, C.; Collins, K. K.; Dare, M.; Fetterly, K.; Fisher, J. D.; Hongo, R.; Irefin, S.; Lopez, J.; Miller, J. M.; Perry, J. C.; Slotwiner, D. J.; Tomassoni, G. F. and Weiss, E. (2014). Heart Rhythm Society Expert Consensus Statement on Electrophysiology Laboratory Standards: Process, Protocols, Equipment, Personnel, and Safety. Heart Rhythm, 11 (8): e9-e51.

Handa, B. S.; Li, X.; Baxan, N.; Roney, C. H.; Shchendrygina, A.; Mansfield, C. A.; Jabbour, R. J.; Pitcher, D. S.; Chowdhury, R. A.; Peters, N. S. and Ng, F. S. (2020). Ventricular fibrillation mechanism and global fibrillatory organization are determined by gap junction coupling and fibrosis pattern. Cardiovascular Research, 117 (4): 1078-1090.

Harris, P. and Lysitsas, D. (2015). Ventricular arrhythmias and sudden cardiac death. BJA Education, 16 (7): 221-229.

Ibitoye, M. O.; Hamzaid, N. A.; Abdul Wahab, A. K.; Hasnan, N.; Olatunji, S. O. and Davis, G. M. (2020). SVR modelling of mechanomyographic signals predicts neuromuscular stimulation-evoked knee torque in paralyzed quadriceps muscles undergoing knee extension exercise. Computers in Biology and Medicine, 117: 103614.

Jalife, J. (2000). Ventricular Fibrillation: Mechanisms of Initiation and Maintenance. Annual Review of Physiology, 62 (1): 25-50.

Kleiger, R. E.; Miller, J. P.; Bigger, J. T. and Moss, A. J. (1987). Decreased heart rate variability and its association with increased mortality after acute myocardial infarction. The American Journal of Cardiology, 59 (4): 256-262.

Krittanawong, C.; Zhang, H.; Wang, Z.; Aydar, M. and Kitai, T. (2017). Artificial Intelligence in Precision Cardiovascular Medicine. Journal of the American College of Cardiology, 69 (21): 2657-2664.

Kumar, U. K.; Nikhil, M. B. S. and Sumangali, K. Prediction of breast cancer using voting classifier technique. 2017 IEEE International Conference on Smart Technologies and Management for Computing, Communication, Controls, Energy and Materials (ICSTM), 2-4 Aug. 2017 2017. 108-114.

Lipshultz, S. E.; Law, Y. M.; Asante-Korang, A.; Austin, E. D.; Dipchand, A. I.; Everitt, M. D.; Hsu, D. T.; Lin, K. Y.; Price, J. F.; Wilkinson, J. D. and Colan, S. D. (2019). Cardiomyopathy in Children: Classification and Diagnosis: A Scientific Statement From the American Heart Association. Circulation, 140 (1): e9-e68.

Loyse, G. (2017). raspberry-pi Documentation.

Makowski, D.; Pham, T.; Lau, Z. J.; Brammer, J. C.; Lespinasse, F.; Pham, H.; Schölzel, C. and Chen, S. H. A. (2021). NeuroKit2: A Python toolbox for neurophysiological signal processing. Behavior Research Methods, 53 (4): 1689-1696.

Malik, H.; Bashir, U. and Ahmad, A. (2022). Multi-classification neural network model for detection of abnormal heartbeat audio signals. Biomedical Engineering Advances, 4: 100048.

Mehra, R. (2007). Global public health problem of sudden cardiac death. Journal of Electrocardiology, 40 (6, Supplement 1): S118-S122.

Moody, G. B. and Mark, R. G. (2001). The impact of the MIT-BIH Arrhythmia Database. IEEE Engineering in Medicine and Biology Magazine, 20 (3): 45-50.

Moody, G. B.; Mark, R. G. and Goldberger, A. L. PhysioNet: a research resource for studies of complex physiologic and biomedical signals. Computers in Cardiology 2000. Vol.27 (Cat. 00CH37163), 24-27 Sept. 2000 2000. 179-182.

Noble, W. S. (2006). What is a support vector machine? Nature Biotechnology, 24 (12): 1565-1567.

Pai, S. S. 2011. Ventricular Fibrillation. In: (ed.)^(eds.) Essence of Anesthesia Practice. Elsevier.

Pandey, S. K.; Janghel, R. R. and Vani, V. (2020). Patient Specific Machine Learning Models for ECG Signal Classification. Procedia Computer Science, 167: 2181-2190.

Papakyriakou, D. and Barbounakis, I. (2023). Benchmarking and Review of Raspberry Pi (RPi) 2B vs RPi 3B vs RPi 3B+ vs RPi 4B (8GB). International Journal of Computer Applications, 185: 975-8887.

Parker, A.; Heflin, A. and Jones, L. C. (2021). Analyzing University of Virginia Health publications using open data, Python, and Streamlit. J Med Libr Assoc, 109 (4): 688-689.

Ramanathan, T. T.; Hossen, J. and Sayeed, S. (2022). Naïve Bayes Based Multiple Parallel Fuzzy Reasoning Method for Medical Diagnosis. Journal of Engineering Science and Technology, 17 (1): 472-490.

Shaffer, F. and Ginsberg , J. P. (2017). An Overview of Heart Rate Variability Metrics and Norms. Frontiers in Public Health, 5: 258.

Song, Y. Y. and Lu, Y. (2015). Decision tree methods: applications for classification and prediction. Shanghai Arch Psychiatry, 27 (2): 130-5.

Srinivasan, N. T. and Schilling, R. (2018). Sudden Cardiac Death and Arrhythmias. Arrhythmia & Electrophysiology Review, 7 (2): 111-117.

Tang, S.-Y.; Ma, H.-P.; Lin, C.; Lo, M.-T.; Lin, L.-Y.; Chen, T.-Y.; Wu, C.-K.; Chiang, J.-Y.; Lee, J.-K.; Hung, C.-S.; Liu, L.-Y. D.; Chiu, Y.-W.; Tsai, C.-H.; Lin, Y.-T.; Peng, C.-K. and Lin, Y.-H. (2023). Heart rhythm complexity analysis in patients with inferior ST-elevation myocardial infarction. Scientific Reports, 13 (1): 20861.

Tsuji, H.; Larson, M. G.; Venditti, F. J.; Manders, E. S.; Evans, J. C.; Feldman, C. L. and Levy, D. (1996). Impact of Reduced Heart Rate Variability on Risk for Cardiac Events. Circulation, 94 (11): 2850-2855.

Tsuruoka, Y.; Tsujii, J. I. and Ananiadou, S. Stochastic gradient descent training for l1-regularized log-linear models with cumulative penalty. Proceedings of the Joint Conference of the 47th Annual Meeting of the ACL and the 4th International Joint Conference on Natural Language Processing of the AFNLP, 2009. 477-485.

Udawat, A. S. and Singh, P. (2022). An automated detection of atrial fibrillation from single‑lead ECG using HRV features and machine learning. Journal of Electrocardiology, 75: 70-81.

Variability., H. R. (1996). Standards of measurement, physiological interpretation, and clinical use. Task Force of the European Society of Cardiology and the North American Society of Pacing and Electrophysiology. European Heart Journal, 17 (3): 354-381.

Vyas, P. and Pandit, D. (2018). Heartbeat abnormality detection using machine learning models and rate variability (HRV) data.

Werner, K.; Kander, K. and Axelsson, C. (2016). Electrocardiogram interpretation skills among ambulance nurses. European Journal of Cardiovascular Nursing, 15 (4): 262-268.

Zabor, E. C.; Reddy, C. A.; Tendulkar, R. D. and Patil, S. (2022). Logistic Regression in Clinical Studies. International Journal of Radiation Oncology*Biology*Physics, 112 (2): 271-277.