Next Article in Journal
From Pixels to Insights: Unsupervised Knowledge Graph Generation with Large Language Model
Previous Article in Journal
Enhancing E-Recruitment Recommendations Through Text Summarization Techniques
Previous Article in Special Issue
AI-Based Breast Cancer Detection System: Deep Learning and Machine Learning Approaches for Ultrasound Image Analysis
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Early Heart Attack Detection Using Hybrid Deep Learning Techniques

by
Niga Amanj Hussain
and
Aree Ali Mohammed
*
Computer Science Department, College of Science, University of Sulaimani, Sulaymaniyah 46001, Iraq
*
Author to whom correspondence should be addressed.
Information 2025, 16(5), 334; https://doi.org/10.3390/info16050334
Submission received: 15 March 2025 / Revised: 14 April 2025 / Accepted: 17 April 2025 / Published: 22 April 2025

Abstract

:
Given the significant risk that heart disease, particularly heart attacks, poses to individuals’ lives, it is crucial to develop effective techniques for early detection. Advanced machine learning and deep learning algorithms have the ability to predict heart attacks by analyzing a patient’s medical history and overall health. These algorithms can process large datasets, extracting valuable insights that help mitigate the risk of fatal outcomes. This study integrates a deep learning approach to predict and detect heart attacks early by classifying patient data as normal or abnormal. The proposed model combines a Convolutional Neural Network (CNN) with self-attention, leveraging the self-attention mechanism to focus on the most critical aspects of the sequence. Since heart attack risk is closely tied to the changes in vital signs over time, this approach enables the model to learn and assign appropriate weights to each input component. Improvements and modifications to the hybrid model resulted in a 98.71% accuracy rate during testing. The model’s strong performance on evaluation metrics shows its potential effectiveness in detecting heart attacks.

1. Introduction

The global population has undergone significant changes in recent decades, impacting various aspects of society—particularly health and healthcare systems. These shifts have created a pressing need for substantial improvements in healthcare services [1]. Diseases affecting the heart, especially Cardiovascular Diseases (CVDs), are the primary reason for sickness along with death globally, contributing to more than 70% of global fatalities. The 2017 Global Burden of Disease study discovered CVD to be responsible for more than 43% of all deaths. [2]. According to the literature, 2.8 billion individuals die from heart problems because of being overweight, which impacts blood pressure fluctuations, cholesterol levels, and—most importantly—the impact of stress hormones on heart conditions [3]. In 2008, 17.3 million individuals lost their lives to heart disease. According to World Health Organization (WHO) estimates, heart disease will claim the lives of over 23.6 million people by 2030 [4]. The loss of a portion of the heart muscle is known as a myocardial infarction or heart attack. Blood flow to the heart organ will be interrupted or stopped because of this heart muscle loss. In both humans and animals, the heart’s primary job is to pump blood into the circulatory system; if one of its ventricles malfunctions, the heart is assaulted, which eventually results in death if resuscitation is not performed promptly [5]. As a result, even before seeking medical attention, a patient may die from these kinds of unexpected attacks [6]. Epidemiological research shows that heart disease risk is ‘reversible’, indicating that decreasing risk factors can reduce or delay occurrences [7]. Due to heart disease’s often silent progression, timely intervention through monitoring and prediction is crucial [8]. AI and machine learning can anticipate heart attacks based on a patient’s health and medical history, reducing the risk of death [6]. The technique of machine learning has numerous applications. It also demonstrates its impact on heart disease identification [9]. Many investigations attempted to predict heart attacks using machine learning [10]. Machine learning (ML) can effectively provide accurate predictions with decision support [11]. With wearable Internet of Things (IoT) devices, medical records taken from the patient’s body are analyzed to determine the risk of CVDs using machine learning [12]. Machine learning algorithms make predictions on real-time data and learn from historical data. Algorithms can manage big data and extract valuable insights [13]. When comparing feature selection ML algorithms for heart attack anticipation, Naive Bayes, Support Vector Machine (SVM), and K-Nearest Neighbors (KNN) were shown to be the most optimal classifiers [6].
Different studies and works in this field used various types of machine learning models [14,15,16,17,18].
Following several tests and analyses, this study offers some important advances in the medical field. The following summarizes the key contributions provided by this study:
The design of a sophisticated deep learning technique for the early detection and prediction of heart attacks, using patients’ systolic blood pressure (SysBP), diastolic blood pressure (DBP), and heart rate (HR) data.
Modifications and improvements to the CNN model make it suitable and efficient for the proposed work. Using a time-series technique, the model will forecast future risk based on previous patterns. CNNs are very scalable and perform effectively with large time-series datasets.
Using the attention mechanism (self-attention) with the CNN model, the attention layer learns to focus on the most important time steps. Instead of considering all prior time steps equally, it gives more weight to important occasions (for example, a sudden increase in blood pressure).
The developed deep learning model accurately identified heart attacks, achieving a 98% accuracy rate.
This paper follows this structure: Section 2 presents a comprehensive review of all relevant studies, and Section 3 details the methodology, including the design and implementation of the proposed deep learning method. Section 4 outlines training and assessing the deep learning model, performance assessment, evaluation metrics, and result analysis. Furthermore, there is an in-depth discussion of how the ideal model became better. Finally, Section 5 provides conclusions and recommendations for future research in this area.

2. Related Works

Early identification of cardiac problems reduces the need for medical facilities. It allows the healthcare system to both manage illnesses and prevent fatalities. Researchers conducted multiple studies to predict heart disease with neural networks and traditional machine learning approaches. This section summarizes and offers a thorough analysis of various studies undertaken focused on heart disease and heart attack prediction.
Tomov et al.’s [19] key objective is to create, evaluate, and optimize Deep Neural Network (DNN) architectures with a greater depth of heart disease detection. This research presented a five-layer DNN model, termed Heart Evaluation for Algorithmic Risk-reduction and Optimization five (HEARO-5), which demonstrated a remarkable accuracy of 99%.
Khade et al. [20] proposed techniques such as Boosted Decision Tree (for detection), CNN (for subtype estimate), and anticipating potential negative outcomes, demonstrating the usage of CNN alongside classic machine learning techniques. When the Decision Tree’s (DT) probability exceeds a certain threshold, the CNN layer reliably detects heart failure. A boosted Decision Tree and the CNN module are utilized to diagnose heart failure. The SVM algorithm is utilized to diagnose heart failure type with an accuracy of 84%. An Artificial Neural Network measures the severity of heart failure with 88.30% accuracy.
Pasha et al. [21] examined different algorithms, including SVM, KNN, DT, Artificial Neural Networks (ANN), and TensorFlow Keras, using comparisons of their accuracy levels on a heart attack dataset gathered from Kaggle. Previous techniques exhibited low performance and accuracy when applied to large datasets. To enhance prediction accuracy, ANN, along with TensorFlow Keras, was employed. The accuracy of a binary model using an ANN is 85.24%, which is higher than other approaches.
In Yuanyuan Pan et al. [18], an Enhanced Deep learning-assisted Convolutional Neural Network (EDCNN) was created to enhance cardiovascular prognostics. It employs a more sophisticated architecture that integrates weight regularization methods and multi-level perception networks. Based on routine clinical data, EDCNN shows promising outcomes through the formation and refinement of architectures to improve the identification of cardiovascular conditions across an expanded domain.
The authors, Hussain et al. [22], introduced a new deep learning architecture that uses a 1D convolutional neural network to classify healthy and unhealthy individuals using balanced datasets. This methodology addresses the limitations associated with conventional machine learning techniques. The algorithm employs an embedding layer to refine and reformat the feature vector into a representation suited for classification. The model with dropout achieves 97.79% training and 96.77% test accuracy, compared to multiple classifiers, including Logistic Regression, SVM, DT, Random Forest, XGBoost, and ANN, which are outperformed by the one-dimensional Convolutional Neural Networks (1D CNNs) architecture.
Komalavalli et al. [23] proposed a TensorFlow model that used machine learning to identify key features and improve prediction accuracy for cardiovascular illness. Analytical methods are employed to gather data and data preprocessing. The model was optimized to obtain the loss function using a binary classification technique. The proposed TensorFlow framework, built upon advanced neural architectures, demonstrated exceptional accuracy in predicting cardiac illness.
The authors Bharti et al. [24] compared the findings and analysis of the UCI Machine Learning Heart Disease dataset using a variety of machine learning algorithms and deep learning techniques. They developed three methods for comparison and evaluation and generated significant results. Ultimately, it was determined that the deep learning model, which included dense layers, dropout, ReLU, and sigmoid activation, outperformed in this analysis. The dataset needs to be normalized, as failure to do so results in an over-fitted training model and insufficient accuracy. The discovery of outliers is also critical, and this is managed through a method called Isolation Forest.
Gupta et al. [6] employed supervised machine learning classifiers such as Gradient Boosting, DT, Random Forest, and Logistic Regression to develop a model for predicting myocardial infarction. The ultimate model for predicting cardiac arrest used a Gradient Boosting Classifier. The gradient boosting technique achieved the highest accuracy, which enabled a binary classification of a heart attack (1 or 0). Using the Gradient Boosting Classifier, an average accuracy of 85.5% and an 82% recall rate was achieved in the Framingham dataset.
Wu et al. [25] proposed a system that measures vital signs with wearable medical devices and then extracts relevant information using various deep learning techniques. DNN is a machine learning subfield based on the way the human brain operates. Several factors led to the preference for the DNN over traditional machine learning approaches. Because they relied on a single-layer framework, traditional learning algorithms are inefficient at processing intricate datasets with strong nonlinear patterns, when traditional machine learning approaches require human skills or feature engineering to select the best attributes for accurate predictions.
Mehmood et al. [26] introduced Cardio Help, a method that used CNN to predict the existence of cardiovascular illness in patients. They employed a well-established dataset and an advanced CNN machine learning technique to predict cardiac disease. The dataset was divided into two categories: Heart_Disease and No_Heart_Disease. The method focused on temporal data modelling and used CNN for early HF prediction. CNN is used to classify input into binary classes, and the resulting model is saved to the file system. Finally, it achieves 97% accuracy.
Arooj et al. [27] applied the CNN algorithm to the preprocessed data to forecast heart illnesses on Google Colab. The experimental design of the suggested model aimed to evaluate the CNN performance with the dataset from the UCI repository. The system was assessed concerning performance metrics of accuracy, and it was accomplished with 91.71%. To decrease overall loss and enhance model accuracy, they used the Nadam optimization technique with our suggested CNN algorithm. It employs the same learning rate alpha to update weights and trains somewhat quicker than Adam. This study focuses on identifying cardiovascular conditions through image classification using deep learning, Deep Convolutional Neural Networks (DCNNs).
Nancy et al. [28] proposed a method that uses the fuzzy inference system (FIS) and Recurrent Neural Network (RNN) Bidirectional Long Short-Term Memory (Bi-LSTM) for predicting tasks. Three different models were tested, utilizing a standard Long Short-Term Memory (LSTM) model to predict diseases. The following model, FLSTM, integrates the FIS and the LSTM network, with FIS initially classifying patients’ heart disease risk status and the LSTM model used for prediction. The model, known as FBiLSTM, predicts cardiac conditions by combining FIS and Bi-LSTM. A Fuzzy Inference System (FIS) is employed to categorize cardiovascular risk using patient data and a 98.85% accuracy was attained.
Kadhim et al. [29] model has three phases: collecting and processing records from patients, training and evaluating them using machine learning techniques (Random Forest, SVM, KNN, and DT). The Random Forest method achieved the highest classification rate (94.958%), and the findings were further refined with random search, a hyperparameter optimization method [30].
Islam et al. [12] proposed IoT and ML to classify users into three risk levels of CVD (high, moderate, and low) with an F1 score of 80.4% as well as two risk levels (high and low) with an F1 score of 91%. The stacking classifier, which included the best-performing ML techniques, was applied to predict the end-user level of risk using the UCI Repository dataset. It aimed to identify the most effective machine learning technique to detect CVD risk. The study tested 11 ML algorithms for predicting cardio-vascular disorders and used hardware to gather data from users in real-time. Two-stacking classifier models, the developed stacking classifier, attained a 91% score in both precision and recall for two zones and 81.6% and 79.3% for three zones.
In Islam et al. [30], a pre-trained deep learning model using a CNN with an attention layer is used. If any critical irregularities are discovered, the user is automatically connected with the closest physician for additional diagnostics. The method improved efficiency for heart disease classification by using CNN models with attention layers. Attention techniques help the network selectively emphasize critical parts of the input, ensuring that the most relevant information is given priority during processing. Small electronic devices and wearable sensors capture live physiological data, while advanced deep learning algorithms help identify potential health concerns at an early stage.
Lu et al. [14] propose wearable ECG sensors with CNN for early diagnosis of cardiorespiratory problems during pandemics. The preprocessed data are fed into the CNN model, which classifies normal and pathological cardiovascular events. The CNN approach uses labelled data together with ideal parameters to train to obtain high anomaly identification accuracy. The CNN model, which helps medical professionals diagnose patients quickly, can properly detect many health conditions.
Dritsas et al. [31] examined how well five popular deep learning (DL) techniques performed on a dataset used to predict heart attacks: Multi-Layer Perceptron (MLP), CNN, RNN, LSTM, Gated Recurrent Unit (GRU), and a hybrid model. The experimental results indicated that all metrics were outperformed by the hybrid model; the hybrid model achieved 91% accuracy and 89% precision, demonstrating its greater capacity to forecast heart attacks. By leveraging CNN’s feature extraction and GRU’s temporal processing, the model successfully captured spatial and temporal connections.
Significant research gaps remain in ML models for predicting heart attacks, highlighting areas where current methodologies struggle, lose effectiveness, or lack real-world applicability.
The following are the significant gaps identified:
  • Traditional methods for machine learning, (such as SVM, Random Forests, and DT) rely on explicit feature engineering, which may ignore hidden features. There is a lack of multimodal data integration.
  • Most machine learning models rely on a single source of data (for example, ECG or blood pressure), ignoring other complementary elements, such as medical history and lifestyle. Apply multi-modal deep learning models (e.g., CNN-LSTM-Attention) to incorporate BP, HR, ECG, and EHR for increased accuracy.
  • Limited Use of Temporal and Sequence Data Analysis: Many machine learning algorithms regard heart attack prediction as a static classification, missing time-dependent features in BP, HR, and ECG signals.
  • They fail to detect incremental changes that may suggest a heart attack. Model time series data to improve trend analysis.
  • Overfitting from data limitations: Because deep learning algorithms are extremely data-hungry, training them on limited or unbalanced datasets (e.g., a few heart attack events) leads to overfitting. Dropout approach and L2 regularization help avoid overfitting.
Employing a hybrid CNN with an attention mechanism for heart attack prediction can significantly contribute to the field.
  • Better Feature Extraction from Time-Series Data: Processed time-series representations of heart rate and blood pressure are examples of structured data from which CNNs excel at extracting spatial and temporal features. The attention mechanism helps the model focus on critical events that indicate an elevated heart attack risk, such as sudden spikes or unusual patterns in blood pressure and heart rate.
  • Improved Accuracy in Detecting Subtle Patterns: The hybrid CNN with an attention mechanism can automatically prioritize the most relevant areas of clinical data, detecting subtle and complex temporal patterns that might go unnoticed. This allows the model to concentrate on crucial periods of heart rate variability, blood pressure spikes, and other unexpected changes, thereby improving its predictive capabilities for cardiac conditions.
  • Higher Interpretability and Explainability: The attention mechanism provides visual insights into the parts of the input data that most influence the model’s predictions, enhancing interpretability. By highlighting specific features or regions of heart rate or blood pressure that are critical for heart attack prediction, it enables doctors to understand better and trust the model’s results.
  • Preventing Overfitting with Hybrid Approaches: The hybrid approach combines CNNs (effective at feature extraction) with attention mechanisms (which refine feature importance), making it more resistant to overfitting. The attention layer improves generalization by encouraging the model to focus only on the most essential features, reducing the likelihood of overfitting, and helping the model learn generalizable patterns rather than memorizing individual examples.
  • Real-Time, High-Accuracy Prediction with Temporal Records: The hybrid CNN with an attention mechanism is designed to extract both spatial and temporal information, making it highly effective at identifying heart attacks in real time.
  • Eliminating Noise and Redundant Features: Not all values in raw physiological data are equally useful for prediction. The attention layer prioritizes significant features while minimizing the impact of noise and unnecessary variations.
A comparison of related works in heart disease prediction, including datasets, models used, and performance metrics, is presented in Table 1.

3. Methodology

This section presents the proposed model, including the design of the deep learning architecture and the selection process used to identify the optimal configuration for accurate heart attack prediction.

3.1. Dataset Preparation

Following extensive research and consultation with field specialists, we chose blood pressure (systolic and diastolic) and heart rate as the key features. The dataset that we first worked with had 71,760 records and many features (ID, age, sex, SysBP, DBP, HR, weightKg, heightCm, BMI, and indication) that not all are required for heart attack detection. We removed the unrequired features and their data, updating the dataset to include only the three key features (SysBP, DBP, HR) that significantly affect heart attack detection. This updated dataset contains three features, each with suitable values for heart attack prediction, and a binary label column (0 for normal, 1 for abnormal).
At the end of the dataset preparation, the updated dataset, containing all three features and the label column that determines the record’s state (normal or abnormal), is divided into two datasets: one for the normal state, containing records with ‘0’ in the label column, and one for the abnormal state, which includes records indicating heart attack risk, with ‘1’ in the label column.

3.2. Customized Kaggle Dataset

The Health Heart Experimental dataset (from Health_heart_experimental.csv), published on Kaggle, was initially used in its original form, containing 71,761 records and a variety of features, including ID, age, sex, SysBP, DBP, HR, weightKg, heightCm, BMI, and indication. However, not all of these features were necessary for heart attack detection. After reviewing the dataset, only the three most critical features—Systolic Blood Pressure (SysBP), Diastolic Blood Pressure (DBP), and Heart Rate (HR)—were retained, while the irrelevant features and their associated records were removed.
The next step involved determining the specific combination of these three feature values that could indicate a heart attack. After extensive experimentation, the following condition was selected as the threshold for detecting abnormal cases:
SysBP ≥ 130 AND DBP ≥ 60 AND Heart Rate ≥ 70
This condition was carefully chosen. For instance, in some cases where SysBP was significantly high but DBP was below 80, using a higher DBP threshold (e.g., ≥80) would misclassify abnormal cases as normal. Therefore, DBP was set to ≥60, because when DBP is less than 60, it indicates low diastolic pressure—even if SysBP is high. This adjustment helps ensure that potentially abnormal cases are not mistakenly labeled as normal. Similarly, a heart rate of 70 bpm or higher was used to indicate elevated heart rate levels, which are often associated with increased cardiovascular risk.
After applying the condition,
  • Records meeting the condition were labeled 1 (abnormal);
  • All others were labeled 0 (normal).
The dataset was then split into two separate CSV files:
  • One for normal cases (Label = 0);
  • One for abnormal cases (Label = 1).
Sample of Original Filtered Dataset (Before Sequence Reshaping)
IndexSysBPDBPHRLabel
011598840
113297841
2137981620
3121921661
4130891120
5122941501
6113921220
7142991691
813880810
9145951791
101441081750
111391171760
To enable deep learning models to detect temporal patterns, the dataset was later reshaped into sequences of six timesteps, where the final record determines the label of the sequence.
Reshaped Time-Series Sequences (Example)
SeqT1T2T3T4T5T6Label
1(115,98,84)(132,97,84)(137,98,162)(121,92,166)(130,89,112)(122,94,150)1
2(113,92,122)(142,99,169)(138,80,81)(145,95,179)(144,108,175)(139,117,176)0

3.3. Data Preprocessing

In the data preparation phase, data cleaning, formatting, shuffling, and splitting are performed. Start by reshaping the dataset into time series or sequences for the deep learning model built with TensorFlow r2.17/Keras 2.0 in Google Colab. After importing the necessary libraries, load the data from two separate CSV files: one for normal data and one for abnormal data. Create a list of data frames called DFS and specify the file paths for loading the data. DFS [0] contains the normal data frame, where the label values are all 0, and DFS [1] contains the abnormal data frame, where the label values are all 1.
  • Splitting to Train and Test
    • Takes X and Y and splits a set of the data, with 70% for training.
    • Splits the remaining 30% for testing.
    • The dataset is 70% training and 30% testing.
  • Reshaping the dataset to time series sequences
    • Reshape train and test sets with six time steps.
    • Converted X_train and X_test into 3D tensors (samples, time steps, features).
    • Selecting the last label of each sequence (for regression or single-class classification); keep only the last label for each sequence that the model predicates the final value from the sequence.

3.4. Build Model

The proposed model is a hybrid CNN with an attention mechanism. Various modifications are incorporated into this model for heart attack detection, as clearly presented in Figure 1.
First, enter the data as a sequence with time steps = 6 and features = 3. Using sequential data allows the model to anticipate future outcomes, rather than simply classifying a single snapshot. Since heart attack risk is determined by changes in vital signs over time, employing time steps significantly enhances the model’s accuracy and robustness. Three 1D Convolutional (Conv1D) layers then process the input for feature extraction; the Conv1D is especially well-suited for processing sequential data such as time series.
Some modifications were made for efficient training and to prevent overfitting problems:
  • EarlyStopping
    • Keeps track of validation loss or val_loss.
    • Training ends early if val_loss does not increase for five epochs in a row.
    • restore_best_weights = True ensures the model returns to the best weights discovered during training after quitting.
    • Prevents overfitting, saves time and resources, and achieves optimal performance on validation data for the final model.
  • ReduceLROnPlateau (Learning Rate Scheduler)
    • Observes val_loss.
    • The learning rate lowers by a factor of 0.5 if val_loss stops improving for three consecutive epochs.
    • To keep the learning rate from becoming too low, it is set at a minimum of 0.0001.
    • It improves convergence, enhances generalization, and reduces the learning rate to break plateaus in stuck training.
  • Hyperparameters
    • Validation_split = 0.2 → Uses 20% of the training data for validation. From the 70% set to training, the model splits 20% to validation. Validation data, a subset of the training data, evaluates the model’s performance during and after each epoch. Without using the test set, it aids in hyperparameter tuning and helps avoid overfitting.
    • Batch_size = 16 → Processes 16 samples at a time.
    • Epochs = 120 → Sets a max of 120 training epochs (but early stopping may end it earlier).
    • Callbacks [early stopping, lr_scheduler] → Uses the callbacks to optimize training.
  • The Model Configuration Before Training
    Optimizer: Adam (Adaptive Moment Estimation)
    • Adam: It helps in faster convergence.
    • Loss Function: ‘binary_crossentropy’ Used for binary classification problems (e.g., predicting 0 or 1).
    • Metrics:
    • ‘accuracy’ → Measures the percentage of correctness in predictions.
    • tf.keras.metrics. Area Under the Curve (AUC) (name = ‘auc’) → Computes the (AUC-ROC)

3.5. Optimized Model Selection

Instead of running the model multiple times to track results, the model is optimized in a single run to identify and select the best result as the optimal model. It will run five times and save the best results, and the output will be the best model with the best result. This comparison of each run (validation accuracy, validation loss, and accuracy gap) determines the best model. The selection of the best model is based on
  • Highest Validation Accuracy (val_accuracy > best_accuracy);
  • Lowest Validation Loss (val_accuracy == best_accuracy and val_loss < best_loss);
  • Smallest Gap between Validation and Train Accuracy (val_accuracy == best_accuracy and val_loss == best_loss and gap < smallest_gap).
As a result, the best model is the one with the highest validation accuracy, or if the validation accuracy is the same, the model with the lowest validation loss is selected. If both validation accuracy and validation loss are the same, the best model is updated to the one with the smallest accuracy gap. The gap is the difference between training and validation accuracy. Figure 2 presents the selection of the optimal model among the five model runs.

4. Results and Discussion

The proposed model provides optimal results for heart attack detection using sequential data. The model, selected from multiple runs, achieved the following results: Accuracy: 98.71%, AUC: 0.9994, Test Accuracy: 98.86%, and Test AUC: 0.9996. The optimal loss and accuracy curves for both the training and test datasets demonstrate the model’s ability to minimize overfitting. The criteria for selecting the best model are based on the highest validation accuracy, lowest validation loss, and the smallest training–validation accuracy gap (overfitting control).
Our AI/ML model leverages a CNN with self-attention applied to time-series data of SYSBP, DBP, and HR to predict the risk of heart attack. The clinical significance of these physiological parameters in cardiovascular risk stratification is well-established in the literature. For instance, the 2017 ACC/AHA/AAPA/ABC/ACPM/AGS/APhA/ASPC/NMA/PCNA Guideline for the Prevention, Detection, Evaluation, and Management of High Blood Pressure in Adults [32] emphasizes the strong association between elevated blood pressure and increased risk of atherosclerotic cardiovascular disease, the primary cause of myocardial infarction. Furthermore, a study by Fox et al. [33] indicated that elevated resting heart rate is associated with an increased risk of cardiovascular events and mortality, independent of other risk factors.
While traditional risk assessment tools often rely on static measurements of these vital signs collected during infrequent clinical visits, our model capitalizes on the dynamic information inherent in continuous time-series data. This approach aligns with a growing understanding in the clinical community that the temporal patterns and variability of blood pressure and heart rate can provide valuable insights into an individual’s cardiovascular health beyond single snapshots [34]. Our use of CNNs with self-attention is motivated by their ability to automatically learn complex temporal patterns and focus on the most relevant periods within the time series, potentially capturing subtle physiological changes that may precede an acute event.
The potential of our model to analyze continuous streams of SYSBP, DBP, and HR data, possibly from wearable devices, could offer a more real-time and personalized approach to heart attack risk prediction compared to current methods. For example, the model might identify patterns of nocturnal hypertension or increased heart rate variability that are known clinical markers of elevated risk but are not always captured during routine office visits. By providing a continuous risk assessment, our model could potentially trigger earlier interventions and lifestyle modifications in high-risk individuals, ultimately aiming to reduce the incidence of heart attacks. Future work will focus on validating our model’s predictions against real-world clinical outcomes and exploring its integration into existing diagnostic workflows to assess its impact on patient care.
Figure 3 displays a comparison result of the traditional CNN, improved CNN, and hybrid CNN–Self-Attention models. The first model, with 1DConv layer, yields 90% accuracy. The improved CNN model, which is an improvement of the traditional CNN using three Conv1D layers and more additional improvements, raised the accuracy to 92%. Finally, the hybrid model gives the highest accuracy for heart attack detection, at 98%.
A CNN model along with an attention layer was trained in the experiment to classify data into two groups, normal and abnormal, for heart attack detection. A total accuracy rate of 98.71% was accomplished by the model, demonstrating the effectiveness of the model in distinguishing between a heart attack and a normal state.
Figure 4 shows the accuracy curve using 120 epochs and when an early stop is of patience 5.
Figure 5 shows the loss curve using 120 epochs and when an early stop is of patience 5.
Table 2 presents the F1-score, recall, and precision for all classes; This classification report shows that the model performed extremely well on the given dataset.
Figure 6 presents the model’s Receiver Operating Characteristic (ROC) curve and AUC; with a value of 0.9996, it is extremely near to 1.
  • This demonstrates the model’s ability to almost perfectly differentiate ‘Heart Attack’ cases from ‘No Heart Attack’ cases.
  • The two classes are nearly perfectly separated by the model.
  • Due to the high spike at the beginning, there are very few false negatives and false positives.
This study’s findings suggest that this model has potential as a diagnostic tool in heart attack detection.
The proposed dataset (Customized Kaggle Dataset) was used to train several models—RNN, LSTM, GRU, and BiLSTM—which are well-suited for time-series data, particularly in the field of heart disease and heart attack detection. Figure 7 shows a comparison of the performance between these models and the proposed model. The proposed model stands out as the better choice, achieving high accuracy without overfitting.
Table 3 demonstrates a comparison between earlier research that used different machine learning algorithms and the proposed hybrid CNN–Attention model, which uses sequential data and achieved the highest accuracy.

5. Conclusions and Perspectives for the Future

This research proposes a hybrid CNN model with an attention layer. The self-attention mechanism utilizes attention weights to highlight the most important portions of the sequential data, thereby enhancing the CNN’s performance. Tracking the fluctuations in blood pressure and heart rate within the time-series data improves the attention layer’s effectiveness in predicting heart attacks across a six-time series with 71,760 records. The development of this model incorporates several advanced techniques, such as regularization to enhance generalization, a one-dimensional CNN for more effective pattern extraction, and optimization to select the best model based on evaluation metrics across five model runs. The optimized model is then saved for reloading and future use. The proposed model successfully classifies normal and abnormal heart attack states, facilitating earlier identification of heart attacks and potentially reducing mortality. It achieved an AUC of 0.9996, demonstrating near-perfect classification with high precision and recall and few false positives. The model also achieved an overall accuracy of 98.71% and a test accuracy of 98.86%, indicating strong performance in distinguishing between heart attack and normal states. In conclusion, by leveraging these features and combining the CNN model with the attention layer, the proposed model demonstrates exceptional accuracy in heart attack detection.
Despite the promising findings of this study, several areas for improvement remain to be explored for further investigation and development. These include expanding the dataset to incorporate additional crucial features that influence heart attack detection, as well as extending the time series range to allow the attention layer to function more effectively by focusing on and assigning greater weight to the most significant components.

Author Contributions

Conceptualization, N.A.H. and A.A.M.; methodology, N.A.H.; formal analysis, A.A.M.; investigation, N.A.H.; writing—original draft preparation, N.A.H.; writing—review & editing, A.A.M.; visualization, N.A.H. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

This study was conducted in accordance with the Declaration of Helsinki and was approved by the University of Sulaimani Ethics Committee. The protocol code is Univsul-2407171-025. The approval date is not required because it varies with IRB renewal.

Informed Consent Statement

Not applicable.

Data Availability Statement

The original contributions presented in this study are included in the article. Further inquiries can be directed to the corresponding author.

Acknowledgments

This research is a part of MSc research work at the University of Sulaimani in Kurdistan Region of Iraq. Special thanks are due to the College of Science for providing a healthy environment to fulfil this project.

Conflicts of Interest

The author certifies that there is no actual or potential conflict of interest concerning this article.

References

  1. Wan, J.; AAHAl-awlaqi, M.; Li, M.; O’Grady, M.; Gu, X.; Wang, J.; Cao, N. Wearable IoT enabled real-time health monitoring system. EURASIP J. Wirel. Commun. Netw. 2018, 2018, 298. [Google Scholar] [CrossRef]
  2. Bhatt, C.M.; Patel, P.; Ghetia, T.; Mazzeo, P.L. Effective heart disease prediction using machine learning techniques. Algorithms 2023, 16, 88. [Google Scholar] [CrossRef]
  3. Momin, M.A.; Bhagwat, N.S.; Dhiwar, A.V.; Chavhate, S.B.; Devekar, N.S. Smart body monitoring system using IoT and machine learning. engrXiv 2021. [Google Scholar] [CrossRef]
  4. Yahyaie, M.; Tarokh, M.J.; Mahmoodyar, M.A. Use of internet of things to provide a new model for remote heart attack prediction. Telemed. J. e-Health 2019, 25, 499–510. [Google Scholar] [CrossRef]
  5. Abba, S.; Garba, A.M. An IoT-based smart framework for a human heartbeat rate monitoring and control system. Proceedings 2020, 42, 36. [Google Scholar]
  6. Gupta, S.K.; Shrivastava, A.; Upadhyay, S.P.; Chaurasia, P.K. A machine learning approach for heart attack prediction. Int. J. Eng. Adv. Technol. 2021, 10, 124–134. [Google Scholar] [CrossRef]
  7. Taylor, O.E.; Ezekiel, P.S.; Deedam-Okuchaba, F.B. A model to detect heart disease using machine learning algorithm. Int. J. Comput. Sci. Eng. 2019, 7, 1–5. [Google Scholar] [CrossRef]
  8. Khan, M.A. An IoT framework for heart disease prediction based on MDCNN classifier. IEEE Access 2020, 8, 34717–34727. [Google Scholar] [CrossRef]
  9. Lakshmanarao, A.; Swathi, Y.; Sundareswar, P.S. Machine learning techniques for heart disease prediction. Forest 2019, 95, 97. [Google Scholar]
  10. Ghosh, P.; Azam, S.; Jonkman, M.; Karim, A.; Shamrat, F.J.; Ignatious, E.; Shultana, S.; Beeravolu, A.R.; De Boer, F. Efficient prediction of cardiovascular disease using machine learning algorithms with relief and LASSO feature selection techniques. IEEE Access 2021, 9, 19304–19326. [Google Scholar] [CrossRef]
  11. Rao, G.M.; Ramesh, D.; Sharma, V.; Sinha, A.; Hassan, M.M.; Gandomi, A.H. AttGRU-HMSI: Enhancing heart disease diagnosis using hybrid deep learning approach. Sci. Rep. 2024, 14, 7833. [Google Scholar] [CrossRef]
  12. Islam, M.N.; Raiyan, K.R.; Mitra, S.; Mannan, M.R.; Tasnim, T.; Putul, A.O.; Mandol, A.B. Predictis: An IoT and machine learn-ing-based system to predict risk level of cardio-vascular diseases. BMC Health Serv. Res. 2023, 23, 171. [Google Scholar] [CrossRef]
  13. Sharma, V.; Yadav, S.; Gupta, M. Heart disease prediction using machine learning techniques. In Proceedings of the 2020 2nd International Conference on Advances in Computing, Communication Control and Networking (ICACCCN), Greater Noida, India, 18–19 December 2020; pp. 177–181. [Google Scholar]
  14. Lu, H.; Feng, X.; Zhang, J. Early detection of cardiorespiratory complications and training monitoring using wearable ECG sensors and CNN. BMC Med. Inform. Decis. Mak. 2024, 24, 194. [Google Scholar] [CrossRef] [PubMed]
  15. Begum, S.S.; Mashl, H.A.; Karthikeyan, B.; Alanazi, F.Z. A prediction of heart disease using IoT based ThingSpeak basis and deep learning method. J. Adv. Res. Appl. Sci. Eng. Technol. 2024, 47, 166–179. [Google Scholar] [CrossRef]
  16. Ramesh, T.R.; Lilhore, U.K.; Poongodi, M.; Simaiya, S.; Kaur, A.; Hamdi, M. Predictive analysis of heart diseases with machine learning approaches. Malays. J. Comput. Sci. 2022, 132–148. [Google Scholar]
  17. Jindal, H.; Agrawal, S.; Khera, R.; Jain, R.; Nagrath, P. Heart disease prediction using machine learning algorithms. IOP Conf. Ser. Mater. Sci. Eng. 2021, 1022, 012072. [Google Scholar] [CrossRef]
  18. Pan, Y.; Fu, M.; Cheng, B.; Tao, X.; Guo, J. Enhanced deep learning assisted convolutional neural network for heart disease prediction on the internet of medical things platform. IEEE Access 2020, 8, 189503–189512. [Google Scholar] [CrossRef]
  19. Tomov, N.S.; Tomov, S. On deep neural networks for detecting heart disease. arXiv 2018, arXiv:1808.07168. [Google Scholar]
  20. Khade, S.; Subhedar, A.; Choudhary, K.; Deshpande, T.; Kulkarni, U. A system to detect heart failure using deep learning techniques. Int. Res. J. Eng. Technol. 2019, 6, 384–387. [Google Scholar]
  21. Pasha, S.N.; Ramesh, D.; Mohmmad, S.; Harshavardhan, A. Cardiovascular disease prediction using deep learning techniques. IOP Conf. Ser. Mater. Sci. Eng. 2020, 981, 022006. [Google Scholar] [CrossRef]
  22. Hussain, S.; Nanda, S.K.; Barigidad, S.; Akhtar, S.; Suaib, M.; Ray, N.K. Novel deep learning architecture for predicting heart disease using CNN. In Proceedings of the 2021 19th OITS International Conference on Information Technology (OCIT), Bhu-baneswar, India, 16–18 December 2021; pp. 353–357. [Google Scholar]
  23. Komalavalli, D.; Sangeethapriya, R.; Indhu, R.; Kanimozhi, N.; Kasthuri, G. An Effective Heart Disease Prediction Using Ma-chine Learning. ICTACT J. Soft Comput. 2021, 11, 2323–2337. [Google Scholar]
  24. Bharti, R.; Khamparia, A.; Shabaz, M.; Dhiman, G.; Pande, S.; Singh, P. Prediction of heart disease using a combination of ma-chine learning and deep learning. Comput. Intell. Neurosci. 2021, 2021, 8387680. [Google Scholar] [CrossRef] [PubMed]
  25. Wu, X.; Liu, C.; Wang, L.; Bilal, M. Internet of things-enabled real-time health monitoring system using deep learning. Neural. Comput. Appl. 2021, 35, 14565–14576. [Google Scholar] [CrossRef] [PubMed]
  26. Mehmood, A.; Iqbal, M.; Mehmood, Z.; Irtaza, A.; Nawaz, M.; Nazir, T.; Masood, M. Prediction of heart disease using deep convolutional neural networks. Arab. J. Sci. Eng. 2021, 46, 3409–3422. [Google Scholar] [CrossRef]
  27. Arooj, S.; Rehman, S.U.; Imran, A.; Almuhaimeed, A.; Alzahrani, A.K.; Alzahrani, A. A deep convolutional neural network for the early detection of heart disease. Biomedicines 2022, 10, 2796. [Google Scholar] [CrossRef] [PubMed]
  28. Nancy, A.A.; Ravindran, D.; Raj Vincent, P.D.; Srinivasan, K.; Gutierrez Reina, D. Iot-cloud-based smart healthcare monitoring system for heart disease prediction via deep learning. Electronics 2022, 11, 2292. [Google Scholar] [CrossRef]
  29. Kadhim, M.A.; Radhi, A.M. Heart disease classification using optimized Machine learning algorithms. Iraqi J. Comput. Sci. Math. 2023, 4, 31–42. [Google Scholar] [CrossRef]
  30. Islam, M.R.; Kabir, M.M.; Mridha, M.F.; Alfarhood, S.; Safran, M.; Che, D. Deep learning-based IoT system for remote moni-toring and early detection of health issues in real-time. Sensors 2023, 23, 5204. [Google Scholar] [CrossRef]
  31. Dritsas, E.; Trigka, M. Application of Deep Learning for Heart Attack Prediction with Explainable Artificial Intelligence. Com-puters 2024, 13, 244. [Google Scholar] [CrossRef]
  32. Whelton, P.K.; Carey, R.M.; Aronow, W.S.; Casey, D.E.; Collins, K.J.; Dennison Himmelfarb, C.; DePalma, S.M.; Gidding, S.; Jamerson, K.A.; Jones, D.W.; et al. 2017 ACC/AHA/AAPA/ABC/ACPM/AGS/APhA/ASH/ASPC/NMA/PCNA guideline for the prevention, detection, evaluation, and management of high blood pressure in adults: A report of the American College of Cardiology/American Heart Association Task Force on Clinical Practice Guidelines. J. Am. Coll. Cardiol. 2018, 71, e127–e248. [Google Scholar]
  33. Fox, K.; Borer, J.S.; Camm, A.J.; Danchin, N.; Ferrari, R.; Lopez Sendon, J.L.; Steg, P.G.; Tardif, J.C.; Tavazzi, L.; Tendera, M.; et al. Resting heart rate in cardiovascular disease. J. Am. Coll. Cardiol. 2007, 50, 823–830. [Google Scholar] [CrossRef] [PubMed]
  34. Kikuya, M.; Hozawa, A.; Ohokubo, T.; Tsuji, I.; Michimata, M.; Matsubara, M.; Ota, M.; Nagai, K.; Araki, T.; Satoh, H.; et al. Prognostic significance of blood pressure and heart rate variabilities: The Ohasama study. Hypertension 2000, 36, 901–906. [Google Scholar] [CrossRef] [PubMed]
Figure 1. General diagram of the proposed hybrid model.
Figure 1. General diagram of the proposed hybrid model.
Information 16 00334 g001
Figure 2. Optimized best model selection flowchart.
Figure 2. Optimized best model selection flowchart.
Information 16 00334 g002
Figure 3. Results comparison chart.
Figure 3. Results comparison chart.
Information 16 00334 g003
Figure 4. Accuracy Curve for Training and Validation.
Figure 4. Accuracy Curve for Training and Validation.
Information 16 00334 g004
Figure 5. Loss Curve for Training and Validation.
Figure 5. Loss Curve for Training and Validation.
Information 16 00334 g005
Figure 6. The Proposed Model’s ROC Curve.
Figure 6. The Proposed Model’s ROC Curve.
Information 16 00334 g006
Figure 7. Accuracy Comparison of Different Models.
Figure 7. Accuracy Comparison of Different Models.
Information 16 00334 g007
Table 1. Comparison of related works.
Table 1. Comparison of related works.
ReferenceYearDataset UsedModels UsedPerformance Metrics
[19]2018Cleveland dataset (303 patients, 13 attributes)Deep Neural Networks (DNN), HEARO-5 (five-layer DNN)accuracy: 99%, 0.98 MCC
[20]2019Custom dataset (10,801 patients) and FANATASIA dataset (ECG recordings)Boosted Decision Tree, (CNN), (SVM), (ANN)accuracy: CNN—High, SVM—84%, ANN—88.3%
[21]2020Kaggle Heart Disease Dataset(SVM), (KNN), (DT), (ANN)accuracy: SVM—81.97%, KNN—67.2%, DT—81.97%, ANN—85.24%
[18]2020UCI Heart Disease DatasetEnhanced Deep Learning-Assisted Convolutional Neural Network (EDCNN) (CNN + MLP + Bayesian Networks)precision: 99.1%
accuracy: High (Exact not specified)
specificity: High
sensitivity: 97.51%
[22]2021Cleveland Dataset1D Convolutional Neural Network (CNN)accuracy: 97%,
test accuracy: 96%,
precision, recall, F1-score
[23]2021UCI ML Repository- TensorFlow-based Neural Network (Binary Classifier)
- Machine Learning Algorithms
accuracy: High (Exact values not provided)
sensitivity and specificity: Evaluated (Exact values not provided)
[24]2021UCI Heart Disease Dataset (Cleveland, Hungary, Switzerland, Long Beach V)Deep Learning (Sequential Model with Dense Layers, Dropout, ReLU, and Sigmoid activation)accuracy: 94.2%
sensitivity: 82.3%
specificity: 83.1%
[6]2021Framingham Heart Study, UCI Heart RepositoryGradient Boosting, Decision Tree, Random Forest, Logistic Regressionaccuracy: 85.5% (Gradient Boosting highest) for framingham dataset, 85.6% (Gradient Boosting highest) for UCI dataset.
precision, recall
[25]2021Real-time health data from Sanda athleteDeep Neural Networks (DNNs)precision, recall, AUC, F1-score
[26]2021Custom Heart Disease Dataset(DCNN)accuracy: 97%
[27]2022UCI Heart Disease DatasetDeep Convolutional Neural Network (DCNN)accuracy: 91.7%, precision, recall, F1-score
[28]2022- IoT sensor data
- UCI Cleveland and Hungarian Dataset
Bi-LSTM (Proposed), Comparison with LSTM and FLSTM (FIS + LSTM), Fuzzy Inference System (FIS)accuracy: 98.86%
precision: 98.9%
recall: 98.81%
F1-score: 98.86%
[29]2023Integrated dataset from IEEE-data portRandom Forest, Support Vector Machines, K-Nearest Neighbor, Decision Treeaccuracy: 95.4% after optimization
[12]2023UCI Heart Disease Dataset (920 samples)Two-Level Classification (Presence or Absence): XGB, KNN, MLPC
Three-Level Classification (Low, Moderate, High risk of CVD): SVM, KNN, XGB
F1-score: 91% (Two-level classification), 80.4% (Three-level classification)
[30]2023MIT-BIH Arrhythmia DatabaseConvolutional Neural Network (CNN) with Attention Layeraccuracy: 98.2%, F1-score: 98.0%
[14]2024Wearable sensor-based datasetConvolutional Neural Networks (CNNs)sensitivity: 95%
specificity: 92%
[31]2024Cleveland DatasetMulti-Layer Perceptron (MLP), CNN, Recurrent Neural Network (RNN), LSTM (GRU), Hybrid Model (integrates CNN and GRU)accuracy: 91%
precision: 89%
recall: 90%
F1-score: 89%, AUC: 0.95
Table 2. Results of classification utilizing the developed model.
Table 2. Results of classification utilizing the developed model.
Classification Report:
PrecisionRecallF1-ScoreSupport
No Heart Attack0.990.990.992133
Heart Attack0.990.980.991455
Accuracy 0.993588
Macro avg0.990.990.993588
Weighted avg0.990.990.993588
Table 3. Performance comparison with reviewed works.
Table 3. Performance comparison with reviewed works.
ReferenceYearDataset UsedModels UsedAccuracy
[24]2021UCI Heart Disease Dataset (Cleveland, Hungary, Switzerland, Long Beach V)Deep Learning (Sequential Model with Dense Layers, Dropout, ReLU, and Sigmoid activation)accuracy: 94.2%
[27]2022UCI Heart Disease DatasetDeep Convolutional Neural Network (DCNN)accuracy: 91.7%
[30]2023MIT-BIH Arrhythmia DatabaseConvolutional Neural Network (CNN) with Attention Layeraccuracy: 98.2%
[31]2024Cleveland DatasetMulti-Layer Perceptron (MLP), CNN, RNN, LSTM, GRU, Hybrid Model (integrates CNN and GRU)accuracy: 91%
The Proposed Model2025Customized Kaggle Heart Disease DatasetHybrid Model (CNN with Attention Mechanism)accuracy: 98.71%
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Hussain, N.A.; Mohammed, A.A. Early Heart Attack Detection Using Hybrid Deep Learning Techniques. Information 2025, 16, 334. https://doi.org/10.3390/info16050334

AMA Style

Hussain NA, Mohammed AA. Early Heart Attack Detection Using Hybrid Deep Learning Techniques. Information. 2025; 16(5):334. https://doi.org/10.3390/info16050334

Chicago/Turabian Style

Hussain, Niga Amanj, and Aree Ali Mohammed. 2025. "Early Heart Attack Detection Using Hybrid Deep Learning Techniques" Information 16, no. 5: 334. https://doi.org/10.3390/info16050334

APA Style

Hussain, N. A., & Mohammed, A. A. (2025). Early Heart Attack Detection Using Hybrid Deep Learning Techniques. Information, 16(5), 334. https://doi.org/10.3390/info16050334

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop