Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

❤️ Heart Stroke Risk Prediction

A Machine Learning web application that predicts the risk of heart disease based on patient medical information.

The project includes a complete machine learning workflow, from data preprocessing and feature selection to model training, evaluation, model saving, and deployment with Streamlit.

🌐 Live Demo

Open the Live Application

📌 Project Overview

This project uses patient medical information to predict whether a person is at risk of heart disease.

The trained machine learning model is integrated into a Streamlit frontend where users can enter patient information and receive a prediction through an interactive interface.

✨ Features

  • ❤️ Heart disease risk prediction
  • 🖥️ Interactive Streamlit frontend
  • 🌙 Dark/premium UI
  • 📱 Responsive interface for mobile and desktop
  • 📊 Multiple machine learning models tested
  • 🔍 Feature selection using Mutual Information and Chi-Square
  • ⚙️ Numerical feature scaling using StandardScaler
  • 💾 Saved trained model and preprocessing objects
  • 🚀 Deployed using Streamlit Community Cloud

🧠 Machine Learning Workflow

The project follows these main steps:

Dataset
   ↓
Data Preprocessing
   ↓
Feature Encoding
   ↓
Feature Selection
   ↓
Train / Test Split
   ↓
Feature Scaling
   ↓
Model Training
   ↓
Model Evaluation
   ↓
Model Selection
   ↓
Model Saving
   ↓
Streamlit Frontend
   ↓
Deployment

🔍 Feature Selection

Two feature-selection techniques were used:

Mutual Information

Mutual Information was used to measure the relationship between individual features and the target variable.

Chi-Square Test

The Chi-Square test was used to evaluate the relationship between categorical features and the target.

Features were analyzed using both methods before building the final model.

🤖 Models Tested

The following classification models were evaluated:

  • Logistic Regression
  • K-Nearest Neighbors (KNN)
  • Gaussian Naive Bayes
  • Decision Tree
  • Support Vector Machine (SVM)
  • Random Forest

The models were compared using:

  • Accuracy
  • Precision
  • Recall
  • F1 Score

📊 Model Evaluation

Model Accuracy Precision Recall F1 Score
Logistic Regression 0.861386 0.925926 0.833333 0.877193
KNN 0.851485 0.909091 0.833333 0.869565
Gaussian Naive Bayes 0.854785 0.909639 0.838889 0.872832
Decision Tree 0.831683 0.895706 0.811111 0.851312
SVM 0.867987 0.916667 0.855556 0.885057
Random Forest 0.864686 0.916168 0.850000 0.881844

🏆 Selected Model

Based on the evaluation results, SVM achieved the highest F1 Score and Accuracy among the tested models.

Therefore, SVM was selected as the final model for the deployed application.

🛠️ Technologies Used

  • Python
  • NumPy
  • Pandas
  • Scikit-learn
  • Joblib
  • Streamlit
  • Git & GitHub
  • Streamlit Community Cloud

📂 Project Structure

heart-disease-prediction/
│
├── app.py
├── requirements.txt
├── README.md
│
└── pickles/
    ├── model.pkl
    ├── scalar.pkl
    ├── columns.pkl
    └── columns_to_scale.pkl

⚙️ Local Setup

Clone the repository:

git clone (https://github.com/code-with-ayyan/Heart-Stroke-Risk-Prediction)
cd Heart-Stroke-Risk-Prediction

Install the required dependencies:

pip install -r requirements.txt

Run the Streamlit application:

streamlit run app.py

The application will be available locally at:

http://localhost:8501

🚀 Deployment

The application is deployed using Streamlit Community Cloud.

The GitHub repository is connected to the deployed application, allowing changes pushed to the repository to trigger a new deployment automatically.

⚠️ Disclaimer

This application is an educational machine learning project and should not be used as a medical diagnostic tool.

The prediction is generated by a machine learning model and should not replace professional medical advice or evaluation.

👨‍💻 Author

Ayyan

Machine Learning Project — Heart Disease Prediction

🔗 Live Application

ayyan-heart-stroke-prediction.streamlit.app

About

End-to-end Machine Learning project for predicting heart stroke risk using multiple classification algorithms, with EDA, feature engineering, preprocessing, model evaluation, and an interactive Streamlit web application.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages