Skip to content

About

This project presents a comparative machine learning framework for heart attack risk prediction using Python. It includes data preprocessing, feature engineering, SMOTE for class balancing, cross validation, and performance evaluation of multiple ML models.

Resources

Stars

136 stars

Watchers

0 watching

Forks

Repository files navigation

๐Ÿ“– A Comparative Machine Learning Framework for Heart Attack Risk Prediction

Data Preprocessing โ€ข Class Imbalance Handling โ€ข Cross-Validation โ€ข Predictive Modeling




Overview โ€ข Objectives โ€ข Dataset โ€ข Methodology โ€ข Findings โ€ข Connect


๐Ÿ“– Research Overview

Cardiovascular diseases and heart attacks remain significant global healthcare challenges. Early identification of individuals at risk can support timely medical intervention and improve healthcare decision-making.

This research presents a comparative Machine Learning framework for predicting heart attack risk by integrating systematic data preprocessing, feature preparation, class imbalance handling, hyperparameter optimization, and five-fold cross-validation.

Seven supervised machine learning algorithms are investigated to compare their predictive capabilities and identify their strengths and limitations in healthcare risk prediction.

The research particularly emphasizes the importance of evaluating models beyond accuracy, considering metrics such as Recall, Precision, F1-Score, ROC-AUC, and Confusion Matrices.

Research Focus: Developing and evaluating a systematic machine learning framework that emphasizes reliable heart attack risk prediction and minority-class detection.


๐ŸŽฏ Research Objectives

The primary objectives of this research include:

  • ๐Ÿซ€ Developing a comparative machine learning framework for heart attack risk prediction.
  • ๐Ÿงน Applying systematic data preprocessing and cleaning.
  • ๐Ÿ” Identifying relevant predictive features.
  • โš–๏ธ Addressing class imbalance using SMOTE and class weighting.
  • ๐Ÿค– Comparing multiple supervised machine learning algorithms.
  • โš™๏ธ Optimizing model hyperparameters.
  • ๐Ÿ”„ Applying five-fold cross-validation.
  • ๐Ÿ“Š Evaluating predictive performance using multiple metrics.
  • โค๏ธ Investigating minority-class detection capabilities.
  • ๐Ÿ† Identifying the strengths and limitations of different models.

๐Ÿ“Š Dataset Overview

The research utilizes the Heart Attack Risk Prediction Dataset obtained from Kaggle.

๐ŸŽฏ Target Variable

Heart Attack Risk

The prediction task is formulated as a binary classification problem.

Target Value Description
0 No Heart Attack Risk
1 Heart Attack Risk

๐Ÿ” Dataset Features

The dataset includes demographic, physiological, lifestyle, and clinical-related variables.

Category Features
๐Ÿ‘ค Demographic Age, Sex
โค๏ธ Cardiovascular Cholesterol, Systolic BP, Diastolic BP
๐Ÿšฌ Lifestyle Smoking, Alcohol Consumption, Exercise
๐Ÿฉบ Medical Diabetes, Family History, Previous Heart Problems
โš–๏ธ Physical BMI, Obesity
๐Ÿง  Other Factors Stress Level, Sleep, Physical Activity

๐Ÿ“Œ Dataset Information

Property Details
Dataset Heart Attack Risk Prediction
Source Kaggle
Problem Type Binary Classification
Target Variable Heart Attack Risk
Original Observations 5,022
Original Class Distribution 2,511 per class

๐Ÿ”ฌ Research Methodology

The study follows a quantitative machine learning research methodology.

The proposed framework integrates data preprocessing, feature selection, class balancing, model development, optimization, and performance evaluation.

๐Ÿงญ Research Workflow

              ๐Ÿซ€ HEART ATTACK DATASET
                         |
                         โ–ผ
                ๐Ÿงน DATA PREPROCESSING
                         |
                         โ–ผ
                 ๐Ÿ” FEATURE SELECTION
                         |
                         โ–ผ
               โš–๏ธ CLASS IMBALANCE
                    HANDLING
                         |
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ–ผ                 โ–ผ
              SMOTE         CLASS WEIGHTING
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         |
                         โ–ผ
                ๐Ÿค– MODEL TRAINING
                         |
                         โ–ผ
              โš™๏ธ HYPERPARAMETER
                  OPTIMIZATION
                         |
                         โ–ผ
                 ๐Ÿ”„ FIVE-FOLD CV
                         |
                         โ–ผ
                 ๐Ÿ“Š EVALUATION
                         |
                         โ–ผ
               ๐Ÿ† MODEL COMPARISON
                         |
                         โ–ผ
               ๐Ÿซ€ RISK PREDICTION

The dataset was divided into 80% training and 20% testing data, with five-fold cross-validation used for model validation.


๐Ÿงน Data Preprocessing

Data preprocessing is an essential stage in developing reliable machine learning models.

The research examines several data preparation activities:

  • Handling missing values.
  • Identifying duplicate records.
  • Examining inconsistent observations.
  • Investigating potential outliers.
  • Performing feature preparation.
  • Applying feature selection.
  • Preparing data for machine learning algorithms.

The objective is to improve data quality and establish a consistent foundation for model training and evaluation.


โš–๏ธ Class Imbalance Handling

Class imbalance can affect the ability of machine learning models to identify minority-class observations.

This research incorporates two important approaches:

1. ๐Ÿ”ต Synthetic Minority Oversampling Technique (SMOTE)

SMOTE generates synthetic minority-class observations to improve class representation during model training.

2. ๐ŸŸฃ Class Weighting

Class weighting assigns different importance to classes during model training to help address classification bias.

๐Ÿ“Š SMOTE Distribution

Class Original Distribution After SMOTE
No Heart Attack Risk (0) 2,511 4,499
Heart Attack Risk (1) 2,511 4,499

Important: SMOTE is applied to training data rather than the held-out test data to avoid data leakage.


๐Ÿค– Machine Learning Models

The research compares seven supervised machine learning algorithms.

No. Algorithm Category
01 ๐Ÿ“ˆ Logistic Regression Linear Classification
02 ๐ŸŒณ Decision Tree Tree-Based Learning
03 ๐ŸŒฒ Random Forest Ensemble Learning
04 ๐Ÿš€ Gradient Boosting Boosting Algorithm
05 โšก LightGBM Gradient Boosting
06 ๐Ÿ”ฅ AdaBoost Adaptive Boosting
07 ๐Ÿง  Multi-Layer Perceptron (MLP) Neural Network

๐Ÿ“ˆ Logistic Regression

A statistical classification algorithm used as a baseline for predicting binary outcomes.

๐ŸŒณ Decision Tree

A tree-based learning algorithm that identifies patterns and relationships through decision rules.

๐ŸŒฒ Random Forest

An ensemble learning technique that combines multiple decision trees to improve prediction robustness.

๐Ÿš€ Gradient Boosting

A boosting approach that sequentially develops models to improve predictive performance.

โšก LightGBM

An efficient gradient-boosting framework designed for scalable tree-based learning.

๐Ÿ”ฅ AdaBoost

An adaptive boosting algorithm that focuses on observations incorrectly classified by previous learners.

๐Ÿง  Multi-Layer Perceptron (MLP)

A neural network architecture capable of learning complex nonlinear relationships in structured data.


โš™๏ธ Hyperparameter Optimization

Hyperparameter optimization is incorporated to identify suitable configurations for the machine learning algorithms.

The process aims to improve model performance and establish more effective model configurations.

Optimization Workflow

       MACHINE LEARNING MODEL
                 |
                 โ–ผ
       HYPERPARAMETER SEARCH
                 |
                 โ–ผ
          MODEL VALIDATION
                 |
                 โ–ผ
        FIVE-FOLD CROSS-VALIDATION
                 |
                 โ–ผ
        OPTIMIZED CONFIGURATION
                 |
                 โ–ผ
          FINAL EVALUATION

๐Ÿ”„ Five-Fold Cross-Validation

Five-fold cross-validation is used to assess model performance across different subsets of the training data.

       FOLD 1 โ†’ TRAIN / VALIDATE
       FOLD 2 โ†’ TRAIN / VALIDATE
       FOLD 3 โ†’ TRAIN / VALIDATE
       FOLD 4 โ†’ TRAIN / VALIDATE
       FOLD 5 โ†’ TRAIN / VALIDATE
                    |
                    โ–ผ
          AVERAGE PERFORMANCE

This approach provides a more comprehensive assessment of model performance than relying exclusively on a single validation split.


๐Ÿ“Š Performance Evaluation Metrics

Healthcare prediction requires careful evaluation because identifying high-risk cases is particularly important.

The research incorporates multiple performance metrics.

Metric Purpose
๐ŸŽฏ Accuracy Overall classification correctness
๐Ÿ”Ž Precision Correctness of positive predictions
โค๏ธ Recall Ability to identify actual positive cases
โš–๏ธ F1-Score Balance between precision and recall
๐Ÿ“ˆ ROC-AUC Discrimination between positive and negative classes
๐Ÿงฉ Confusion Matrix Detailed classification outcomes
๐Ÿ“Š Balanced Accuracy Performance across both classes

๐Ÿ† Key Findings

The experimental findings demonstrate that different algorithms perform differently depending on the evaluation criteria.

๐Ÿ“Š Overall Model Comparison

Machine Learning Model Approx. Accuracy Key Observation
๐ŸŒฒ Random Forest 64% Strong overall classification
๐Ÿ“ˆ Logistic Regression 64% Competitive overall performance
๐Ÿš€ Gradient Boosting 63% Strong ensemble performance
โšก LightGBM 62% Competitive predictive performance
๐ŸŒณ Decision Tree 54% Better minority-class detection
๐Ÿง  MLP Neural Network 54% Better heart attack case detection

Values are approximate and based on the reported experimental results.

โค๏ธ Minority-Class Detection

An important finding is that the algorithm achieving the highest overall accuracy is not necessarily the most effective at identifying heart attack-risk cases.

The Decision Tree and MLP Neural Network demonstrated comparatively stronger minority-class detection through higher Recall and F1-Score.

๐Ÿ”ฅ Random Forest Performance

Random Forest achieved approximately:

Metric Performance
Accuracy 64.3%
Precision 49.4%

๐Ÿ“ˆ ROC-AUC Analysis

The reported ROC-AUC values were relatively close to random classification.

This indicates that the models demonstrated limited class-separation capability on the evaluated dataset.

๐Ÿ’ก Important Research Observation

Accuracy alone is insufficient for evaluating healthcare prediction models. Recall, Precision, F1-Score, and ROC-AUC provide additional insights into the ability of models to identify high-risk cases.


๐Ÿ’ก Main Research Contributions

The primary contribution of this research is the development of a systematic comparative machine learning framework integrating:

  • ๐Ÿงน Comprehensive data preprocessing.
  • ๐Ÿ” Feature selection.
  • โš–๏ธ Class imbalance handling.
  • โš™๏ธ Hyperparameter optimization.
  • ๐Ÿ”„ Five-fold cross-validation.
  • ๐Ÿ“Š Multi-metric performance evaluation.
  • ๐Ÿค– Comparative analysis of seven machine learning algorithms.

The findings highlight the importance of evaluating machine learning models using multiple performance indicators rather than relying exclusively on accuracy.


๐Ÿ› ๏ธ Technologies & Tools

Technology Purpose
๐Ÿ Python Machine learning implementation
๐Ÿ““ Jupyter Notebook Experimental development
๐Ÿผ Pandas Data processing
๐Ÿ”ข NumPy Numerical computation
๐Ÿค– Scikit-learn Machine learning algorithms
โš–๏ธ Imbalanced-learn SMOTE and class balancing
๐Ÿ“Š Matplotlib Data visualization
๐ŸŽจ Seaborn Statistical visualization
๐Ÿ“ˆ Plotly Interactive visualization
๐Ÿ“‹ SPSS Statistical analysis

๐Ÿ“‚ Repository Structure

A-Comparative-Machine-Learning-Framework/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“„ A Comparative Machine Learning Framework for
โ”‚   Heart Attack Risk Prediction.docx
โ”‚
โ”œโ”€โ”€ ๐Ÿ““ Data-Analysis-with-Python.ipynb
โ”‚
โ”œโ”€โ”€ ๐Ÿ“Š Heart_Attack_Risk_Levels_Dataset.csv
โ”‚
โ””โ”€โ”€ ๐Ÿ“˜ README.md

๐Ÿ“š Research Publication

The research manuscript is also available on ResearchGate for academic accessibility and research dissemination.

๐Ÿ“– Research Title

A Comparative Machine Learning Framework for Heart Attack Risk Prediction Using Data Preprocessing, Class Imbalance Handling, and Cross-Validation.


๐Ÿš€ Future Improvements

Potential directions for extending this research include:

  • ๐Ÿ”ฌ External validation using independent healthcare datasets.
  • ๐Ÿง  Integration of Explainable AI (XAI) techniques.
  • ๐Ÿ“Š SHAP-based feature importance analysis.
  • โšก Advanced ensemble learning approaches.
  • ๐Ÿฉบ Investigation of additional cardiovascular risk factors.
  • ๐Ÿ” Advanced feature selection techniques.
  • ๐Ÿ“ˆ Model calibration and threshold optimization.
  • ๐ŸŒ Development of an interactive prediction interface.

These are potential research extensions and are not claimed as completed implementations.


๐Ÿงช Experimental Setup & Configuration

The experimental framework was designed to evaluate multiple machine learning algorithms under a consistent data preparation and validation strategy.

โš™๏ธ Experimental Configuration

Configuration Description
๐ŸŽฏ Learning Task Binary Classification
๐Ÿ“Š Dataset Heart Attack Risk Prediction
๐Ÿ”€ Train-Test Split 80:20
๐Ÿ”„ Cross-Validation 5-Fold
โš–๏ธ Imbalance Handling SMOTE and Class Weighting
๐Ÿค– Algorithms 7 Machine Learning Models
๐Ÿ“ˆ Evaluation Multiple Classification Metrics
๐Ÿ Programming Language Python

๐Ÿ”ฌ Experimental Strategy

  • Consistent preprocessing across model experiments.
  • Training and testing data separation.
  • Class imbalance handling within the training process.
  • Hyperparameter optimization.
  • Cross-validation-based performance assessment.
  • Comparative evaluation of classification results.

Research Principle: Fair model comparison requires consistent experimental conditions, appropriate validation, and reliable performance evaluation.


๐Ÿ“Š Model Evaluation & Performance Analysis

Machine learning models are evaluated using multiple performance indicators to understand their classification capabilities.

๐Ÿ“ˆ Evaluation Dimensions

Evaluation Metric Research Importance
๐ŸŽฏ Accuracy Overall predictive correctness
๐Ÿ” Precision Reliability of positive predictions
โค๏ธ Recall Identification of actual positive cases
โš–๏ธ F1-Score Balance between Precision and Recall
๐Ÿ“ˆ ROC-AUC Classification discrimination
๐Ÿงฉ Confusion Matrix Classification error analysis

๐Ÿ† Performance Interpretation

The comparative analysis highlights an important distinction between overall classification accuracy and minority-class identification.

A model with higher accuracy does not necessarily provide better detection of heart attack-risk cases.

Therefore, Recall and F1-Score are particularly important when interpreting the predictive performance of healthcare classification models.

Key Insight: Model selection should consider the intended application and the relative importance of false negatives and false positives, rather than accuracy alone.


๐Ÿ” Reproducibility & Research Transparency

Reproducibility is an important aspect of scientific machine learning research.

This repository provides supporting research materials to help readers understand the experimental methodology and research framework.

๐Ÿ“š Available Research Resources

Resource Purpose
๐Ÿ“„ Research Manuscript Research methodology and findings
๐Ÿ““ Jupyter Notebook Experimental implementation
๐Ÿ“Š Dataset Supporting data for analysis
๐Ÿ“˜ README Documentation Project overview and methodology

๐Ÿ”ฌ Research Transparency

The repository is intended to support:

  • Understanding the experimental workflow.
  • Reviewing the machine learning methodology.
  • Examining the selected classification algorithms.
  • Exploring preprocessing and class balancing strategies.
  • Understanding model evaluation and reported findings.

Reproducibility depends on using the same dataset version, preprocessing operations, feature configuration, random seeds, and model settings described in the research.


๐Ÿง  Research Limitations

Although this research investigates multiple machine learning approaches for heart attack risk prediction, several limitations should be considered.

โš ๏ธ Identified Research Considerations

  • Dataset Dependency: Experimental findings depend on the characteristics and quality of the selected dataset.
  • Generalizability: Results may not directly generalize to different populations or healthcare environments.
  • Class Discrimination: Relatively low ROC-AUC performance indicates limitations in distinguishing between the two classes.
  • Feature Dependency: Predictive performance may depend on the availability and quality of input variables.
  • Clinical Validation: The experimental framework has not established clinical effectiveness through independent real-world validation.

๐Ÿ’ก Research Implications

These considerations highlight the need for independent datasets, improved feature engineering, advanced machine learning methods, explainability techniques, and clinical validation.

Research Perspective: Machine learning predictions should be interpreted carefully, particularly in high-impact healthcare applications.


๐Ÿ”ฎ Research Impact & Academic Significance

This research contributes to the broader investigation of machine learning applications in healthcare risk prediction.

๐ŸŒŸ Academic Significance

  • ๐Ÿ“š Provides a comparative investigation of seven machine learning algorithms.
  • ๐Ÿงน Highlights the importance of systematic data preprocessing.
  • โš–๏ธ Examines class imbalance handling in healthcare classification.
  • ๐Ÿ”„ Incorporates cross-validation into model evaluation.
  • ๐Ÿ“Š Demonstrates the importance of multiple performance metrics.
  • ๐Ÿ”ฌ Identifies opportunities for further research in healthcare AI.

๐ŸŒ Potential Research Applications

Research Area Potential Contribution
๐Ÿฅ Healthcare AI Predictive modeling research
๐Ÿซ€ Cardiovascular Research Risk classification studies
๐Ÿค– Machine Learning Comparative algorithm evaluation
๐Ÿ“Š Medical Data Science Data preprocessing and analysis
๐Ÿ” Explainable AI Interpretable predictive systems

๐Ÿ“š How to Cite This Research

If you use, discuss, or reference this research in your academic work, please cite the original manuscript.

๐Ÿ“– Research Publication

Title: A Comparative Machine Learning Framework for Heart Attack Risk Prediction Using Data Preprocessing, Class Imbalance Handling, and Cross-Validation.

Authors: Shahid Azam and Dr. Adnan Amin.

Year: 2026.

๐Ÿ”— Publication Access

๐Ÿ“ BibTeX Reference

@article{azam2026heartattack,
  title={A Comparative Machine Learning Framework for Heart Attack Risk Prediction Using Data Preprocessing, Class Imbalance Handling, and Cross-Validation},
  author={Azam, Shahid and Amin, Adnan},
  year={2026}
}

The BibTeX entry is a provisional citation template, not a verified journal publication record.


๐Ÿ—บ๏ธ Research Roadmap

The following roadmap highlights potential directions for extending the current research framework.

๐Ÿš€ Planned Research Directions

  • ๐Ÿ”ฌ Validate models using independent healthcare datasets.
  • ๐Ÿง  Integrate Explainable Artificial Intelligence (XAI).
  • ๐Ÿ“Š Apply SHAP for feature importance analysis.
  • โšก Investigate advanced ensemble learning techniques.
  • ๐Ÿ” Explore feature selection optimization.
  • ๐Ÿฉบ Investigate additional cardiovascular risk indicators.
  • ๐Ÿ“ˆ Improve model calibration and threshold selection.
  • ๐ŸŒ Develop an interactive research demonstration.

๐Ÿ‘จโ€๐Ÿ’ป Connect With Me

Thank you for exploring my research repository!

I am Shahid Azam, a Computer Science researcher specializing in Artificial Intelligence.

My academic and research interests include Machine Learning, Deep Learning, Artificial Intelligence, Natural Language Processing, Healthcare Analytics, and Intelligent Predictive Systems.

I welcome opportunities for academic collaboration, research discussions, and professional networking.

๐ŸŒ Professional & Academic Profiles

๐Ÿ”ฌ Research Interests

Artificial Intelligence ยท Machine Learning ยท Deep Learning ยท Healthcare AI ยท Predictive Modeling ยท Explainable AI ยท Natural Language Processing ยท Large Language Models


๐Ÿค CONTRIBUTING

Contributions, suggestions, and constructive feedback are welcome!

This repository aims to support academic knowledge sharing and further research in machine learning and healthcare prediction.

๐ŸŒŸ How to Contribute

  1. ๐Ÿด Fork this repository.
  2. ๐Ÿ“ฅ Clone your fork.
  3. ๐ŸŒฟ Create a new branch.
  4. โœ๏ธ Make your proposed improvements.
  5. ๐Ÿ“ค Submit a Pull Request.

๐Ÿ’ก Contribution Areas

Area Possible Contributions
๐Ÿ“š Research Relevant academic publications
๐Ÿค– Machine Learning Additional classification algorithms
โš–๏ธ Class Balancing Advanced imbalance-handling methods
๐Ÿ” Explainability SHAP and other XAI techniques
๐Ÿ“Š Evaluation Additional performance metrics
๐Ÿ“ Documentation Corrections and improvements

๐Ÿซ€ Machine Learning for Smarter Healthcare

Data โ€ข Intelligence โ€ข Prediction โ€ข Research Innovation


Research conducted by Shahid Azam and collaborators

ยฉ 2026 | Academic Research Project


๐ŸŽฏ Long-Term Research Vision

Develop more reliable, interpretable, and generalizable machine learning approaches for healthcare risk prediction.

These items represent potential future research activities, not completed project features.


โš ๏ธ Important Research Disclaimer

This project is intended exclusively for academic, educational, and research purposes.

The machine learning models presented in this study are experimental predictive models and are not intended to replace professional medical diagnosis, clinical judgment, or validated clinical decision-support systems.

The reported results are specific to the dataset and experimental methodology used in this research. Independent clinical validation is necessary before considering any real-world healthcare application.


๐Ÿ“œ License

This repository contains academic research materials, a research manuscript, dataset, and supporting notebook.

No formal license is currently specified for the research materials.

Please contact the author(s) for permission before redistributing or modifying the manuscript or other materials. Any third-party dataset remains subject to its original terms of use.


โญ Support This Research

If you find this research useful for your academic studies, research activities, or professional interests:

  • โญ Star this repository.
  • ๐Ÿ”— Share the research with your academic network.
  • ๐Ÿ“š Read and explore the publication on ResearchGate.
  • ๐Ÿ’ฌ Provide constructive feedback and suggestions.

Your support and academic engagement are appreciated!


About

This project presents a comparative machine learning framework for heart attack risk prediction using Python. It includes data preprocessing, feature engineering, SMOTE for class balancing, cross validation, and performance evaluation of multiple ML models.

Resources

Stars

136 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages