Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Heart-Disease-Risk-Prediction-Using-Machine-Learning

Overview

  • Cardiovascular diseases are among the leading causes of death worldwide. Early identification of individuals at high risk can support preventive care and better health outcomes.

  • This project explores whether demographic, lifestyle, symptom-based, and medical features can be used to predict heart disease risk. Rather than focusing only on model accuracy, the project emphasizes data understanding, cleaning decisions, exploratory analysis, model comparison, and critical reflection on dataset quality.

  • The goal of this work is to demonstrate the full data science workflow, from problem formulation to ethical considerations.

Problem Definition

Can we predict whether an individual is at risk of developing heart disease using demographic, lifestyle, and medical information?

  • Task type: Binary classification

  • Target variable: Heart_Risk

    • 0 → Low risk

    • 1 → High risk

Motivation

  • I chose this problem because it represents a real-world healthcare use case where machine learning can provide meaningful decision support. It also highlights the importance of understanding data quality, confounders, and evaluation metrics when working with sensitive domains such as health.

Dataset Description

  • Source: Kaggle (Heart Disease Risk Prediction Dataset - EarlyMed)

  • Size: 70,000 rows × 19 columns

  • Features:

    • 17 binary indicators (symptoms, lifestyle, medical history)

    • 1 continuous feature (Age)

  • Target: Heart_Risk

Important Note on Data Realism

Through extensive exploration, the dataset was identified as synthetic rather than real-world clinical data, based on:

  • Perfect 50/50 class balance

  • Perfectly balanced binary features

  • Thousands of identical feature combinations

  • Unusually clean and uniform correlations

This dataset is excellent for learning and experimentation, but results should not be interpreted as real medical conclusions.

Data Cleaning & Preparation

  • Verified no missing values in the original dataset

  • Converted all binary features and Age to integer types

  • Investigated duplicate rows and determined they represent valid repeated patterns rather than data errors

  • Demonstrated data-cleaning techniques by intentionally introducing and fixing:

    • Duplicate entries

    • Missing values

    • Unrealistic outliers

A cleaned version of the dataset was saved and used for all modeling experiments.

Exploratory Data Analysis (EDA)

  • Key analyses included:

    • Feature distributions and frequency analysis

    • Age vs. heart risk comparison using boxplots

    • Correlation matrix across all variables

    • Pairwise relationships among major risk factors

    • Investigation of Simpson’s Paradox across demographic and medical subgroups

Key EDA Insights

  • Age is one of the strongest predictors of heart disease risk.

  • Symptom-based features (e.g., chest pain, fatigue) are equally strong predictors.

  • Medical risk factors (high blood pressure, cholesterol, diabetes) show moderate but consistent correlations.

  • No evidence of Simpson’s Paradox was found across examined subgroups.

Modeling Approach

  • Algorithms Evaluated

    1. Logistic Regression

    2. Random Forest

    3. K-Nearest Neighbors (KNN)

    4. Support Vector Machine (SVM)

Feature Engineering

  • All 18 features were retained due to clinical relevance

  • Standard scaling applied for distance-based models

  • Principal Component Analysis (PCA) tested as an extra experiment

Model Selection & Evaluation

  • Models were evaluated using:

    • Accuracy

    • Precision, Recall, F1-score

    • Confusion matrices

    • ROC–AUC

    • 5-fold cross-validation

Best Model

  • Random Forest was selected as the final model because it:

    • Achieved the highest test accuracy (~99.3%)

    • Produced the fewest false negatives (critical in healthcare)

    • Showed strong stability across cross-validation

    • Handled binary features and nonlinear relationships effectively

    • PCA slightly reduced performance and was therefore not used in the final model.

Key Results

  • All evaluated models achieved very high accuracy due to the dataset’s clean separability.

  • Random Forest minimized false negatives, which is crucial for identifying high-risk individuals.

  • ROC–AUC scores were near-perfect across models, further confirming the synthetic nature of the dataset.

Ethical Considerations

  • Predictions should be treated as decision support, not medical diagnoses.

  • Synthetic or unrepresentative data can lead to misleading confidence.

  • Transparency about data limitations is essential.

  • Models trained on such data should never be deployed in real clinical settings without proper validation.

Limitations

  • Dataset is almost certainly synthetic

  • Perfect balance does not reflect real-world prevalence

  • No temporal or longitudinal data

  • No external validation set

Future Work

  • Use real-world, imbalanced clinical datasets

  • Incorporate lab results and time-series health data

  • Validate models on external populations

  • Explore explainability techniques (e.g., SHAP)

Key Takeaways

  • model performance alone is not enough—data understanding matters more

  • EDA can reveal hidden assumptions and data artifacts

  • Healthcare ML requires careful metric selection and ethical reflection

  • Synthetic datasets are useful learning tools but limited for real-world inference

Reproducibility

  • Fixed random seeds used throughout

  • Models and scalers saved for reuse

  • Notebook can be run end-to-end in Google Colab or locally

Final Note

  • This project was completed as part of my first-semester coursework and represents a comprehensive application of data science and machine learning principles, with a strong emphasis on critical thinking, evaluation, and responsible interpretation.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages