Skip to content

pawan0110/MedPredict

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 MedPredict – AI Disease Risk Prediction System

MedPredict is a Machine Learning powered healthcare web application that predicts the probability of major diseases based on patient medical data.

The system currently predicts the risk of:

  • πŸ§ͺ Diabetes
  • ❀️ Heart Disease

Users input medical parameters through a web interface and the system uses trained machine learning models to estimate disease risk.

This project demonstrates the integration of Machine Learning, Flask Web Development, and Cloud Deployment.


🌐 Live Demo

πŸ”— Live Application

https://medpredict-nlff.onrender.com


πŸš€ Features

  • Diabetes Risk Prediction
  • Heart Disease Risk Prediction
  • Real-time ML predictions
  • Risk probability calculation
  • Risk level classification (Low / Moderate / High)
  • Interactive web interface
  • Cloud deployment using Render

πŸ— Project Architecture

User (Browser)
      ↓
HTML Forms
      ↓
Flask Backend (app.py)
      ↓
Machine Learning Models (.pkl)
      ↓
Prediction Result

βš™οΈ Technologies Used

Programming Language

  • Python

Machine Learning

  • Scikit-learn
  • XGBoost
  • Pandas
  • NumPy

Backend

  • Flask

Frontend

  • HTML
  • CSS

Model Storage

  • Joblib

Deployment

  • Render

πŸ“‚ Project Structure

MedPredict
β”‚
β”œβ”€β”€ datasets
β”‚   β”œβ”€β”€ breast_cancer.csv
β”‚   β”œβ”€β”€ diabetes_dataset.csv
β”‚   β”œβ”€β”€ heart.csv
β”‚   β”œβ”€β”€ kidney_disease.csv
β”‚   └── synthetic_heart_disease.csv
β”‚
β”œβ”€β”€ models
β”‚   β”œβ”€β”€ diabetes_model.pkl
β”‚   └── heart_disease_model.pkl
β”‚
β”œβ”€β”€ notebooks
β”‚   β”œβ”€β”€ eda
β”‚   β”‚   β”œβ”€β”€ Diabetes_EDA.ipynb
β”‚   β”‚   └── HeartDiseases_EDA.ipynb
β”‚   β”‚
β”‚   └── model_training
β”‚
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ diabetes_model_testing.py
β”‚   └── heart_disease_testing.py
β”‚
β”œβ”€β”€ static
β”‚   β”œβ”€β”€ images
β”‚   └── style.css
β”‚
β”œβ”€β”€ templates
β”‚   β”œβ”€β”€ home.html
β”‚   β”œβ”€β”€ diabetes.html
β”‚   β”œβ”€β”€ heart.html
β”‚   └── result.html
β”‚
β”œβ”€β”€ app.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .gitignore
└── README.md

πŸ€– Machine Learning Models

The project uses trained classification models saved as .pkl files.

Diabetes Model

The diabetes model predicts whether a patient is diabetic using features like:

  • Gender
  • Age
  • Location
  • Race
  • Hypertension
  • Heart Disease
  • Smoking History
  • BMI
  • HbA1c Level
  • Blood Glucose Level

Prediction is based on probability threshold:

Threshold = 0.45

Heart Disease Model

The heart disease model uses a pipeline model which handles preprocessing automatically.

Input features include:

  • Age
  • Weight
  • Height
  • BMI
  • Hypertension
  • Diabetes
  • Hyperlipidemia
  • Family History
  • Systolic Blood Pressure
  • Diastolic Blood Pressure
  • Heart Rate
  • Fasting Blood Sugar
  • Total Cholesterol
  • Gender
  • Smoking
  • Alcohol Intake
  • Physical Activity
  • Diet
  • Stress Level

Prediction threshold:

Threshold = 0.30

πŸ”„ Application Workflow

1️⃣ User opens the website

Home Page

Options available:

  • Diabetes Prediction
  • Heart Disease Prediction

2️⃣ User enters medical information

Example (Diabetes):

Gender
Age
Location
Race
Hypertension
Heart Disease
Smoking History
BMI
HbA1c Level
Blood Glucose Level

Example (Heart Disease):

Age
Weight
Height
BMI
Blood Pressure
Heart Rate
Blood Sugar
Cholesterol
Lifestyle Factors

3️⃣ Flask receives form data

Example:

age = float(request.form["age"])
bmi = float(request.form["bmi"])
hbA1c_level = float(request.form["hbA1c"])

4️⃣ Data converted to DataFrame

input_df = pd.DataFrame([input_data])

5️⃣ Model prediction

prob = model.predict_proba(input_df)[0][1]

6️⃣ Risk classification

if prob < 0.30 β†’ Low Risk
if prob < 0.60 β†’ Moderate Risk
else β†’ High Risk

7️⃣ Result displayed to user

Example output:

Disease: Diabetes
Prediction: Diabetic
Probability: 67%
Risk Level: High Risk

πŸ“Š Model Evaluation Metrics

Accuracy

Measures overall prediction correctness.

Accuracy = Correct Predictions / Total Predictions

Precision

Measures correctness of predicted positives.

Precision = TP / (TP + FP)

Recall

Measures how many real positive cases were detected.

Recall = TP / (TP + FN)

Confusion Matrix

             Predicted
             No   Yes

Actual No    TN   FP
Actual Yes   FN   TP

πŸ’» Installation (Run Locally)

Clone Repository

git clone https://github.com/pawan0110/MedPredict.git

Navigate to project

cd MedPredict

Create virtual environment

python -m venv venv

Activate environment (Windows)

venv\Scripts\activate

Install dependencies

pip install -r requirements.txt

Run application

python app.py

Open browser

http://127.0.0.1:5000

☁ Deployment

The application is deployed on Render Cloud Platform.

Deployment workflow:

GitHub Repository
        ↓
Render connects to repo
        ↓
Install dependencies
        ↓
Run Flask application
        ↓
Public URL generated

Live App:

https://medpredict-nlff.onrender.com


⚠ Disclaimer

This project is developed for educational and research purposes only.

It should not be used as a medical diagnostic tool or substitute professional healthcare advice.


πŸ‘¨β€πŸ’» Author

Pawan Kumar

GitHub https://github.com/pawan0110


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages