Clear Sky Science · en

Time series electrocardiography (ECG) data for early prediction of cardiac arrest

· Back to index

Why your heartbeat data could save your life

Every beat of your heart leaves an electrical trace, captured in the familiar zigzag lines of an electrocardiogram (ECG). This study shows how modern artificial intelligence can read those traces in real time to warn doctors that a person is heading toward a cardiac arrest or heart attack—before the crisis hits. By comparing different types of computer models, the researchers explore how hospitals and even portable devices might turn continuous ECG monitoring into an early‑warning system for one of the world’s leading killers.

Figure 1
Figure 1.

Understanding danger in the heartbeat

Cardiovascular diseases cover many problems, from clogged arteries and heart attacks to rhythm disorders and weak heart muscle. Many of these conditions share a common pathway: the heart’s electrical system becomes disturbed, raising the risk of a sudden, fatal shutdown. An ECG records this electrical activity as a time series—beats unfolding second by second. Subtle changes in the shape and spacing of these waves can reveal arrhythmias, signs of a heart attack, or damaged conduction pathways well before symptoms become obvious. The challenge is that these patterns are complex and often buried in noisy data, making them hard for humans to detect quickly and consistently, especially in busy clinical settings.

Two ways computers learn from heart signals

The authors focus on two broad families of artificial intelligence that learn from ECG time series. Traditional machine learning starts by turning each heartbeat into a set of numeric features, such as average level, variability, and measures of how spiky or uneven the signal is. Human experts design and select these features, and algorithms like Random Forests, Gradient Boosting, Support Vector Machines, and simple neural networks then learn to tell normal from abnormal beats. Deep learning, by contrast, largely skips manual feature design. Convolutional neural networks (CNNs) and related architectures digest raw ECG signals or ECG images directly, automatically discovering useful patterns across time and frequency. This end‑to‑end style often yields higher accuracy, but at the cost of larger datasets, more computation, and models that can be harder to interpret.

How the study put AI to the test

To compare these approaches fairly, the team drew on two well‑known ECG collections, combining tens of thousands of normal and abnormal beats into a large, but imbalanced, dataset where healthy beats outnumber diseased ones by roughly three to one. For the deep learning track, they converted beats into standardized images and trained a CNN with data augmentation, class weighting, and early stopping to avoid overfitting. For the machine‑learning track, they kept the raw time‑series form, engineered a rich set of statistical features, standardized the data, explored dimensionality reduction, and tuned each model using grid search and five‑fold cross‑validation. They also logged training time and memory use to understand how feasible each method would be for real‑world deployment in resource‑limited clinics.

What the models discovered in the data

Both families of models proved remarkably good at picking out dangerous heart activity, but deep learning came out slightly ahead. The CNN reached about 99.9% accuracy on the image‑based task, while the best machine‑learning model—a Random Forest—achieved about 99.1% accuracy on the feature‑based time‑series data. Other methods, including Gradient Boosting, Support Vector Machines, and a simple multilayer perceptron, also performed strongly. Analyses of confusion matrices, receiver‑operating‑characteristic curves, and precision‑recall curves showed that tree‑based methods and the CNN were particularly strong at detecting abnormal beats without flooding clinicians with false alarms. At the same time, the CNN demanded the most computational power and memory, whereas the simpler models trained faster and would be easier to run on bedside monitors or low‑cost devices.

Figure 2
Figure 2.

Making black‑box predictions more trustworthy

A key concern in medicine is not just whether an algorithm is accurate, but whether doctors can understand what drives its decisions. To tackle this, the researchers applied explainable‑AI tools to both model families. For the feature‑based models, they used a method called SHAP to see which statistics of the ECG mattered most; measures of heart‑rate variability, the shape of the main heartbeat spike (the QRS complex), and segments linked to oxygen supply (the ST section) stood out as top contributors. For the CNN, a visualization technique highlighted the exact regions of the ECG image that influenced the network’s output, again centering on clinically meaningful parts of the waveform. These insights reassure clinicians that the models are focusing on real physiology rather than accidental quirks of the data.

What this means for patients and care teams

In plain terms, this work shows that computers can watch your heartbeat in real time and flag trouble with extraordinary reliability—potentially giving doctors a crucial head start to prevent cardiac arrest or limit heart damage. Deep learning models offer the very highest accuracy but require more data, computing power, and careful validation on modern, diverse patient groups. Simpler machine‑learning models are easier to run and easier to explain, making them attractive for smaller hospitals and wearable devices. Together, these approaches point toward a future where continuous ECG monitoring, guided by transparent AI, becomes a routine safety net against sudden, life‑threatening heart events.

Citation: Umair, M.K., Waheed, R., Abrar, M.F. et al. Time series electrocardiography (ECG) data for early prediction of cardiac arrest. Sci Rep 16, 9761 (2026). https://doi.org/10.1038/s41598-026-35788-9

Keywords: cardiac arrest prediction, ECG time series, deep learning cardiology, machine learning healthcare, artificial intelligence in cardiology