ECG anomaly detection: a deep learning perspective with LSTM encoders

Authors

  • Adenike Adegoke-Elijah
    Department of Computer Science, Faculty of Computing and Digital Technologies, Redeemer’s University, Ede, Osun State, Nigeria
  • Theresa Omolayo Ojewumi
    Department of Computer Science, Faculty of Computing and Digital Technologies, Redeemer’s University, Ede, Osun State, Nigeria
  • Kudirat Oyewumi Jimoh
    Department of Computer Science, Faculty of Computing and Information Technology, Osun State University, Osogbo, Osun State, Nigeria

Keywords:

Anomaly, Anomaly detection, LSTM, Autoencoder, Electrocardiogram, Deep learning

Abstract

An electrocardiogram (ECG) is a procedure that measures the heart’s electrical activity. Each heartbeat generates an electrical impulse, causing the heart muscle to contract and pump blood. ECG data is a classic example of time series data, where the timing of the upper and lower chambers of the heart is analyzed by medical professionals. The use of unsupervised learning techniques, such as K-Means Clustering and Hierarchical Temporal Memory (HTM) to ECG anomaly detection often results in poor performance due to their dependability on pre-defined features. The performance of a multilayer convolutional neural network adapted to the unsupervised task is also constrained by lack of quality feature extraction and guidance from labelled data. This research proposes a deep learning approach using Long-Short Term Memory (LSTM) Networks for the ECG signal analysis to improve the accuracy of anomaly detection in heartbeats. The proposed method was evaluated on the ECG5000 dataset. The model achieved an impressive accuracy of 99.23%, Specificity of 99.25% and Area under curve (AUC) of 98.00%, thereby outperforming existing models. The results demonstrate that the LSTM Autoencoder-based approach effectively learns expressive representations of ECG sequences, leading to improved performance compared to previous methods.

Dimensions

[1] K. Nezamabadi, N. Sardaripour, B. Haghi & M. Forouzanfar, “Unsupervised ECG analysis: a review”, IEEE Reviews in Biomedical Engineering 16 (2023) 208. https://doi.org/10.1109/RBME.2022.3154893. DOI: https://doi.org/10.1109/RBME.2022.3154893

[2] I. Farady, V. Patel, C. Kuo & C.-Y. Lin, “ECG anomaly detection with LSTM-autoencoder for heartbeat analysis”, Proceedings of the IEEE International Conference on Consumer Electronics (ICCE), Las Vegas, NV, USA, 2024, pp. 1–5. https://doi.org/10.1109/ICCE59016.2024.10444327. DOI: https://doi.org/10.1109/ICCE59016.2024.10444327

[3] P. Rani, R. Kumar, A. Jain, R. Lamba, R. K. Sachdeva, K. Kumar & M. Kumar, “An extensive review of machine learning and deep learning techniques on heart disease classification and prediction”, Archives of Computational Methods in Engineering 31 (2024) 3331. https://doi.org/10.1007/s11831-024-10075-w. DOI: https://doi.org/10.1007/s11831-024-10075-w

[4] S. Martin et al., “2024 heart disease and stroke statistics: a report of US and global data from the American Heart Association”, Circulation 149 (2024) 347. https://doi.org/10.1161/CIR.0000000000001209. DOI: https://doi.org/10.1161/CIR.0000000000001247

[5] M. C. Chuah & F. Fu, “ECG anomaly detection via time series analysis”, Proceedings of ISPA Workshops, Niagara Falls, Canada, 2007, pp. 123–135. https://link.springer.com/chapter/10.1007/978-3-540-74767-3_14. DOI: https://doi.org/10.1007/978-3-540-74767-3_14

[6] A. S. Kumar, S. Raja, N. Pritha, H. Raviraj, R. B. Lincy & J. J. Rubia, “An adaptive transformer model for anomaly detection in wireless sensor networks in real-time”, Measurement: Sensors 25 (2023) 100625. https://doi.org/10.1016/j.measen.2022.100625. DOI: https://doi.org/10.1016/j.measen.2022.100625

[7] K. Shaukat, T. M. Alam, S. Luo, S. Shabbir, I. A. Hameed, J. Li, S. K. Abbas & U. Javed, “A review of time-series anomaly detection techniques: a step to future perspectives”, Advances in Information and Communication 1 (2021) 865. https://doi.org/10.1007/978-3-030-73100-7_60. DOI: https://doi.org/10.1007/978-3-030-73100-7_60

[8] A. B. Nassif, A. A. Abd El-Latif, M. M. Abd El-Latif, M. A. Hussein & A. M. Abd El-Latif, “Machine learning for anomaly detection: a systematic review”, IEEE Access 9 (2021) 78658. https://doi.org/10.1007/s42979-025-04352-z. DOI: https://doi.org/10.1007/s42979-025-04352-z

[9] S. Sarvari, N. F. M. Sani, Z. M. Hanapi & M. T. Abdullah, “An efficient anomaly intrusion detection method with feature selection and evolutionary neural network”, IEEE Access 8 (2020) 70651. https://doi.org/10.1109/access.2020.2986217. DOI: https://doi.org/10.1109/ACCESS.2020.2986217

[10] M. S. Elsayed, A. Mohamed & H. Aly, “Network anomaly detection using LSTM based autoencoder”, Proceedings of the 16th ACM Symp. QoS and Security for Wireless and Mobile Networks, Alicante, Spain, 2020, pp. 37–45. https://doi.org/10.1145/3416013.3426457. DOI: https://doi.org/10.1145/3416013.3426457

[11] X. Xia, J. Wang, H. Li, H. Zhang & Y. Li, “GAN-based anomaly detection: a review”, Neurocomputing 493 (2022) 497. https://doi.org/10.1016/j.neucom.2021.12.093. DOI: https://doi.org/10.1016/j.neucom.2021.12.093

[12] M. Elbattah, M. Boussaid & S. Belkadi, “Variational autoencoder for image-based augmentation of eye-tracking data,” Journal of Imaging 7 (2021) 83 2021. https://doi.org/10.3390/jimaging7050083. DOI: https://doi.org/10.3390/jimaging7050083

[13] M. Ibrahim, A. Khan, M. Javed & S. U. Rehman, “Machine learning schemes for anomaly detection in solar power plants”, Energies 15 (2022) 1082. https://doi.org/10.3390/en15031082. DOI: https://doi.org/10.3390/en15031082

[14] W. Cheng, Z. Zhao, Y. Luo, X. Li & H. Zhang, “Anomaly detection for internet of things time series data using GANs with attention mechanism in smart agriculture”, Frontiers in Plant Science 13 (2022) 890563. https://doi.org/10.3389/fpls.2022.890563. DOI: https://doi.org/10.3389/fpls.2022.890563

[15] K. Islam & A. Raza, “Forecasting crime using ARIMA model”, arXiv preprint (2020) [Online]. https://arxiv.org/abs/2003.08006.

[16] Y. M. Zhang, L. Y. Li, Y. Q. Ni & H. F. Lam, “Anomaly detection of structural health monitoring data using the MLE-based Bayesian dynamic linear model”, Structural Health Monitoring 20 (2021) 2936. https://doi.org/10.1177/1475921720977020. DOI: https://doi.org/10.1177/1475921720977020

[17] M. Wu, Z. Luo, Y. Zheng & X. Hu, “A study on Arrhythmia via ECG signal classification using CNN”, Frontiers in Computational Neuroscience 14 (2021) 564015. https://doi.org/10.3389/fncom.2020.564015. DOI: https://doi.org/10.3389/fncom.2020.564015

[18] H. Asif & T. Y. Choe, “Abnormal electrocardiogram signal detection based on the BiLSTM network”, International Journal of Contents 18 (2022) 1. https://doi.org/10.5392/IJoC.2022.18.2.068. DOI: https://doi.org/10.5392/IJoC.2022.18.4.001

[19] P. Matias, J. P. Teixeira & A. Neves, “Robust anomaly detection in time series through variational autoencoders and a local similarity score”, Proceedings of 14th International Joint Conference on Biomedical Engineering Systems and Technologies (BIOSTEC 2021) – BIOSIGNALS, 2021, pp. 91–102. https://doi.org/10.5220/0010320500002865. DOI: https://doi.org/10.5220/0010320500910102

[20] R. V. Lakshmi & S. Radha, “Time series classification using a†tttention-based LSTM and CNN”, Proceedings of International Conference on Data Science, Agents & AI (ICDSAAI), Chennai, India, 2023, pp. 1–7. https://doi.org/10.1109/ICDSAAI59313.2023.10452629. DOI: https://doi.org/10.1109/ICDSAAI59313.2023.10452629

[21] T. M. Ingolfsson, S. Gudmundsson, H. M. Sigurthorsson & K. Kristjansson, “ECG-TCN: wearable cardiac arrhythmia detection with a temporal convolutional network”, Proceedings of IEEE International Conference on Artificial Intelligence Circuits and Systems (AICAS), Washington, DC, USA, 2021, pp. 1–4. https://doi.org/10.1109/aicas51828.2021.9458520. DOI: https://doi.org/10.1109/AICAS51828.2021.9458520

[22] M. Thill, S. D¨aubener, W. Konen, T. B¨ack, P. Baranc´ıkov´a, M. Holena, T. Horvat, M. Pleva & R. Rosa, “Anomaly detection in electrocardiogram readings with stacked LSTM networks”, Proceedings of 19th International Conference on Information Technologies – Applications and Theory (ITAT), Donovaly, Slovakia, 2019 pp. 17–25. http://ceur-ws.org/Vol-2473/paper10.pdf.

[23] S. Zhang, Y. Fang & Y. Ren, “ECG autoencoder based on low-rank attention”, Scientific Reports 14 (2024) 12823. https://doi.org/10.1038/s41598-024-63378-0. DOI: https://doi.org/10.1038/s41598-024-63378-0

[24] M. R. Islam, M. Qaraqe, K. Qaraqe & E. Serpedin, “CAT-Net: convolution, attention, and transformer based network for single-lead ECG arrhythmia classification”, Biomedical Signal Processing and Control 93 (2024) 106211. https://doi.org/10.1016/j.bspc.2024.106211. DOI: https://doi.org/10.1016/j.bspc.2024.106211

[25] L. Shan, Y. Li, H. Jiang, P. Zhou, J. Niu, R. Liu, Y. Wei, J. Peng, H. Yu, X. Sha & S. Chang, “Abnormal ECG detection based on an adversarial autoencoder”, Frontiers in Physiology 13 (2022) 961724. https://doi.org/10.3389/fphys.2022.961724. DOI: https://doi.org/10.3389/fphys.2022.961724

[26] A. Jiang, C. Huang, Q. Cao, S.Wu, Z. Zeng, K. Chen, Y. Zhang & Y.Wang, “Multi-scale cross-restoration framework for electrocardiogram anomaly detection”, Proceedings of International Conference on Medical Image Computing and Computer-Assisted Intervention, (MICCAI), Vancouver, BC, Canada, 2023, pp. 87–97. https://doi.org/10.1007/978-3-031-43907-0_9. DOI: https://doi.org/10.1007/978-3-031-43907-0_9

[27] Q. Du, W. Gu, L. Zhang & S. L. Huang, “Attention-based LSTM-CNNs for time-series classification”, Proceedings of the 16th ACM Conference on Embedded Networked Sensor Systems (SenSys), Shenzhen, China, 2018, pp. 410–411. https://doi.org/10.1145/3274783.3275208. DOI: https://doi.org/10.1145/3274783.3275208

Published

2025-12-29

How to Cite

ECG anomaly detection: a deep learning perspective with LSTM encoders. (2025). African Scientific Reports, 4(3), 359. https://doi.org/10.46481/asr.2025.4.3.359

Issue

Section

MATHEMATICAL SCIENCES SECTION

How to Cite

ECG anomaly detection: a deep learning perspective with LSTM encoders. (2025). African Scientific Reports, 4(3), 359. https://doi.org/10.46481/asr.2025.4.3.359