Skip to content

About

Heart disease prediction web app — Random Forest classifier on 13 patient health inputs (~84% accuracy) with Flask UI and confidence scoring

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heart Disease Predictor

A machine learning web app that predicts whether a patient has heart disease based on their medical details.

Built as Project 1 of a 4-project Machine Learning series using the Zero to Mastery ML course as a learning foundation.


What It Does

  • Takes 13 patient health inputs (age, cholesterol, blood pressure, etc.)
  • Uses a trained Random Forest Classifier to predict heart disease
  • Shows the result with a confidence percentage
  • Green banner = No heart disease detected
  • Red banner = Heart disease detected

Model Performance

Metric Score
Algorithm Random Forest Classifier
Training samples 242 patients
Testing samples 61 patients
Accuracy 83.61%

Tech Stack

Tool Purpose
Python Programming language
Scikit-Learn Machine learning model
Pandas & NumPy Data handling
Flask Web server
HTML & CSS Frontend UI
Joblib Saving/loading the model

How to Run

1. Install dependencies

pip install flask scikit-learn pandas numpy joblib

2. Train the model

python3 train_model.py

3. Start the web app

python3 app.py

4. Open in browser

http://127.0.0.1:5000

Project Files

project1-heart-disease/
├── train_model.py       # Downloads data, trains and saves the model
├── app.py               # Flask web server
├── model.joblib         # Saved trained model (generated after training)
├── templates/
│   └── index.html       # Web page with input form and result
└── static/
    └── style.css        # Styling

Input Features

Feature Description
Age Patient age in years
Sex Male or Female
Chest Pain Type Type of chest pain (4 categories)
Resting Blood Pressure In mm Hg
Cholesterol Serum cholesterol in mg/dl
Fasting Blood Sugar Whether > 120 mg/dl
Resting ECG Heart electrical activity result
Max Heart Rate Maximum heart rate achieved
Exercise Induced Angina Chest pain during exercise
ST Depression (Oldpeak) Depression relative to rest
Slope Slope of peak ST segment
Major Vessels Number of vessels colored by fluoroscopy (0-3)
Thalassemia Blood disorder type

Data Source

Heart Disease Dataset from the Zero to Mastery ML course (originally from UCI Machine Learning Repository).


Disclaimer

This tool is for educational purposes only. Always consult a qualified medical professional for health decisions.


Part of ML Projects Series

Project Description Status
Project 1 Heart Disease Predictor Done
Project 2 Car Price Predictor Coming soon
Project 3 House Price Predictor Coming soon
Project 4 Custom Dataset Predictor Coming soon

About

Heart disease prediction web app — Random Forest classifier on 13 patient health inputs (~84% accuracy) with Flask UI and confidence scoring

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages