Early Heart Attack Detection Using Hybrid Deep Learning Techniques
Abstract
:1. Introduction
- ➢
- 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.
2. Related Works
- 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.
- 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.
3. Methodology
3.1. Dataset Preparation
3.2. Customized Kaggle Dataset
- Records meeting the condition were labeled 1 (abnormal);
- All others were labeled 0 (normal).
- One for normal cases (Label = 0);
- One for abnormal cases (Label = 1).
Index | SysBP | DBP | HR | Label |
0 | 115 | 98 | 84 | 0 |
1 | 132 | 97 | 84 | 1 |
2 | 137 | 98 | 162 | 0 |
3 | 121 | 92 | 166 | 1 |
4 | 130 | 89 | 112 | 0 |
5 | 122 | 94 | 150 | 1 |
6 | 113 | 92 | 122 | 0 |
7 | 142 | 99 | 169 | 1 |
8 | 138 | 80 | 81 | 0 |
9 | 145 | 95 | 179 | 1 |
10 | 144 | 108 | 175 | 0 |
11 | 139 | 117 | 176 | 0 |
Seq | T1 | T2 | T3 | T4 | T5 | T6 | Label |
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
- 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
- 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 TrainingOptimizer: 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
- 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).
4. Results and Discussion
- 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.
5. Conclusions and Perspectives for the Future
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- Khan, M.A. An IoT framework for heart disease prediction based on MDCNN classifier. IEEE Access 2020, 8, 34717–34727. [Google Scholar] [CrossRef]
- Lakshmanarao, A.; Swathi, Y.; Sundareswar, P.S. Machine learning techniques for heart disease prediction. Forest 2019, 95, 97. [Google Scholar]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- Tomov, N.S.; Tomov, S. On deep neural networks for detecting heart disease. arXiv 2018, arXiv:1808.07168. [Google Scholar]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- 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]
- Dritsas, E.; Trigka, M. Application of Deep Learning for Heart Attack Prediction with Explainable Artificial Intelligence. Com-puters 2024, 13, 244. [Google Scholar] [CrossRef]
- 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]
- 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]
- 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]
Reference | Year | Dataset Used | Models Used | Performance Metrics |
---|---|---|---|---|
[19] | 2018 | Cleveland dataset (303 patients, 13 attributes) | Deep Neural Networks (DNN), HEARO-5 (five-layer DNN) | accuracy: 99%, 0.98 MCC |
[20] | 2019 | Custom dataset (10,801 patients) and FANATASIA dataset (ECG recordings) | Boosted Decision Tree, (CNN), (SVM), (ANN) | accuracy: CNN—High, SVM—84%, ANN—88.3% |
[21] | 2020 | Kaggle Heart Disease Dataset | (SVM), (KNN), (DT), (ANN) | accuracy: SVM—81.97%, KNN—67.2%, DT—81.97%, ANN—85.24% |
[18] | 2020 | UCI Heart Disease Dataset | Enhanced 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] | 2021 | Cleveland Dataset | 1D Convolutional Neural Network (CNN) | accuracy: 97%, test accuracy: 96%, precision, recall, F1-score |
[23] | 2021 | UCI 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] | 2021 | UCI 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] | 2021 | Framingham Heart Study, UCI Heart Repository | Gradient Boosting, Decision Tree, Random Forest, Logistic Regression | accuracy: 85.5% (Gradient Boosting highest) for framingham dataset, 85.6% (Gradient Boosting highest) for UCI dataset. precision, recall |
[25] | 2021 | Real-time health data from Sanda athlete | Deep Neural Networks (DNNs) | precision, recall, AUC, F1-score |
[26] | 2021 | Custom Heart Disease Dataset | (DCNN) | accuracy: 97% |
[27] | 2022 | UCI Heart Disease Dataset | Deep 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] | 2023 | Integrated dataset from IEEE-data port | Random Forest, Support Vector Machines, K-Nearest Neighbor, Decision Tree | accuracy: 95.4% after optimization |
[12] | 2023 | UCI 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] | 2023 | MIT-BIH Arrhythmia Database | Convolutional Neural Network (CNN) with Attention Layer | accuracy: 98.2%, F1-score: 98.0% |
[14] | 2024 | Wearable sensor-based dataset | Convolutional Neural Networks (CNNs) | sensitivity: 95% specificity: 92% |
[31] | 2024 | Cleveland Dataset | Multi-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 |
Classification Report: | ||||
---|---|---|---|---|
Precision | Recall | F1-Score | Support | |
No Heart Attack | 0.99 | 0.99 | 0.99 | 2133 |
Heart Attack | 0.99 | 0.98 | 0.99 | 1455 |
Accuracy | 0.99 | 3588 | ||
Macro avg | 0.99 | 0.99 | 0.99 | 3588 |
Weighted avg | 0.99 | 0.99 | 0.99 | 3588 |
Reference | Year | Dataset Used | Models Used | Accuracy |
---|---|---|---|---|
[24] | 2021 | UCI 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] | 2022 | UCI Heart Disease Dataset | Deep Convolutional Neural Network (DCNN) | accuracy: 91.7% |
[30] | 2023 | MIT-BIH Arrhythmia Database | Convolutional Neural Network (CNN) with Attention Layer | accuracy: 98.2% |
[31] | 2024 | Cleveland Dataset | Multi-Layer Perceptron (MLP), CNN, RNN, LSTM, GRU, Hybrid Model (integrates CNN and GRU) | accuracy: 91% |
The Proposed Model | 2025 | Customized Kaggle Heart Disease Dataset | Hybrid 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. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
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
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 StyleHussain, 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 StyleHussain, 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