Skip to content

Arijit2175/Heart-Hero

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

❤️ Heart-Hero - A Heart Disease Prediction Dashboard

An interactive machine learning web application that predicts the probability of heart disease based on patient health parameters and provides explainable insights using SHAP (SHapley Additive Explanations).

This project combines data preprocessing, machine learning, and explainable AI with a clean Streamlit-based user interface to make predictions interpretable and user-friendly.


📌 Features

  • Predicts heart disease probability using a trained ML model

  • User-friendly dashboard built with Streamlit

  • Accepts patient health parameters as input

  • Displays:

    • Prediction result (disease / no disease)
    • Probability score
    • Top contributing features
  • Uses SHAP to explain model predictions

  • Visualizes feature impact using bar charts

  • Allows exporting prediction report as a downloadable file

  • Includes medical disclaimer for responsible use


🧠 Machine Learning Model

  • Algorithm: Random Forest Classifier
  • Trained on a heart disease dataset
  • Preprocessing steps:
    • One-hot encoding for categorical features
    • Feature scaling for numeric features
  • Model accuracy: ~80%

Train the model by running:

python train_model.py

Confusion Matrix

Metrics


📊 Dataset

The dataset contains the following features:

age, sex, cp, trestbps, chol, fbs, restecg, thalach,
exang, oldpeak, slope, ca, thal, target
  • target = 1 → Heart disease
  • target = 0 → No heart disease

🖥️ Dashboard Overview

The application allows users to:

  1. Enter patient details

  2. Click Predict

  3. View:

    • Risk probability
    • Prediction result
    • Feature contributions
    • SHAP explanation chart
  4. Download a detailed prediction report


⚙️ Tech Stack

  • Python
  • Streamlit (Web UI)
  • Scikit-learn (ML model)
  • Pandas, NumPy (Data processing)
  • Matplotlib (Visualization)
  • SHAP (Explainable AI)

🚀 Installation & Setup

1️⃣ Clone the repository

git clone https://github.com/Arijit2175/Heart-Disease-Prediction.git
cd Heart-Disease-Prediction

2️⃣ Install dependencies

pip install -r requirements.txt

3️⃣ Run the app

streamlit run app.py

📝 Usage

  1. Launch the app

  2. Enter patient information

  3. Click Predict

  4. View prediction and explanation

  5. Download the report if needed


🖼️ Dashboard Preview

🔹 Preview 1

Main Dashboard

🔹 Preview 2

Prediction Result


📈 Explainability (SHAP)

SHAP is used to:

  • Show how each feature contributed to the prediction
  • Indicate whether a feature increased or reduced risk
  • Improve transparency and trust in the model

Example explanation:

Chol contributed +0.27 to increased heart disease probability
Max heart rate contributed -0.14 to reduced heart disease probability

⚠️ Disclaimer

This application is for educational purposes only and does not provide medical diagnosis. Predictions are generated by a machine learning model trained on historical data and may not be 100% accurate. Always consult a qualified healthcare professional for medical advice.


📁 Project Structure

Heart-Disease-Prediction/
    ├── app.py
    ├── train_model.py
    ├── dataset/
        └── dataset.csv
    ├── model.pkl
    ├── requirements.txt
    └── README.md

📚 References

  1. N. Pratheek, S. Rajesh, and R. Suresh,
    Cardiovascular Disease Prediction with Machine Learning Algorithms and Interpretation using Explainable AI methods: LIME & SHAP,
    IEEE International Conference on Intelligent Computing and Communication Technologies (ICICCT), 2024.

  2. B. Majhi and A. Kashyap,
    Explainable AI-Driven Machine Learning for Heart Disease Detection Using ECG Signals,
    Applied Soft Computing, Elsevier, 2024.

  3. Shah, P., Patel, M., and Mehta, K.,
    Predicting cardiovascular risk with hybrid ensemble learning and explainable artificial intelligence,
    Scientific Reports, Nature, 2025.

  4. Mushtaq, M., Akram, M., and Khan, S.,
    Causal and Explainable Machine Learning Framework for Heart Disease Prediction using XGBoost and SHAP,
    Journal of Computing and Biomedical Informatics, 2025.

  5. Hussain, S., Alshammari, A., and Raza, A.,
    Interpretable Coronary Heart Disease Prediction using Random Forest, XGBoost, and SHAP-Based Explainability,
    IEEE Access, 2025.

  6. Lundberg, S. M., and Lee, S. I.,
    A Unified Approach to Interpreting Model Predictions,
    Advances in Neural Information Processing Systems (NeurIPS), 2017.


👨‍💻 Developed by - @Arijit2175

About

A ML-based prediction dashboard trained on a large dataset which helps identify if the patient will acquire any heart diseases or not.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages