An ML-powered web app that uses Bayes' Theorem and machine learning to estimate disease likelihood from symptoms — built for students, researchers, and developers.
🚀 Live Demo · 🐛 Report a Bug · 💡 Request a Feature
⚠️ Disclaimer: Educational Use Only This project is for learning and demonstration purposes only. It is not a medical tool and must not be used for real-world diagnosis or treatment. Always consult a qualified healthcare professional.
The Disease Prediction System makes medical reasoning transparent and interactive. It combines classical Bayesian probability with modern ML to show users not just what a prediction is, but why — step by step.
It's designed to bridge the gap between complex statistical concepts and intuitive understanding, with visual charts, AI-powered explanations, and multi-language support.
| Feature | Description |
|---|---|
| Bayes' Theorem Visualizer | Step-by-step breakdown of prior → posterior probability |
| Interactive Sliders | Experiment with probability values in real time |
| Built-in Glossary | Plain-English definitions of medical/statistical terms |
| Feature | Description |
|---|---|
| Symptom-Based Prediction | Select symptoms to get ML-generated probability scores |
| BMI Integration | Height/weight inputs contribute to risk estimation |
| Risk Categorization | Results classified as Low / Medium / High risk |
| Prediction History | Stored timeline of past predictions with analytics |
| Feature | Description |
|---|---|
| AI Explanations | Gemini-powered interpretation of results |
| Next-Step Guidance | Suggests consultation, testing, or lifestyle review |
| Multi-Language Output | English 🇬🇧 · Hindi 🇮🇳 · Gujarati 🇮🇳 · Tamil 🇮🇳 |
| Layer | Technology |
|---|---|
| Backend | Python, Flask |
| Frontend | HTML, CSS, JavaScript |
| ML / Math | Bayesian Inference, ResNet CNN |
| AI | Google Gemini API |
| Dashboard | Streamlit |
| Data | CSV (hospital_data.csv) |
Option 1 — View Online (instant, no setup) 👉 https://disease-prediction-nwnu.onrender.com
Option 2 — Run Locally (30 seconds)
git clone https://github.com/aliviahossain/Disease-prediction.git
cd Disease-prediction
pip install -r requirements.txt
python run.py
Then open your browser at: http://127.0.0.1:5001/
python -m venv venv
source venv/bin/activate # macOS / Linux
venv\Scripts\activate # Windows
pip install -r requirements.txt
Get a free API key from Google AI Studio, then set it:
# Option A: .env file (recommended)
echo "GEMINI_API_KEY=your_key_here" > .env
# Option B: Environment variable
export GEMINI_API_KEY=your_key_here # macOS / Linux
set GEMINI_API_KEY=your_key_here # Windows
python run.py
The application can be deployed to Google Cloud Run.
See: docs/deployment/gcp-cloud-run.md
See docs/deployment/gcp-cloud-run.md for deployment instructions.
The app updates disease probability after observing symptoms or test results using:
P(Disease | Evidence) = [ P(Evidence | Disease) × P(Disease) ]
─────────────────────────────────────────────────────────
[ P(Evidence | Disease) × P(Disease) + P(Evidence | No Disease) × P(No Disease) ]
| Term | Meaning |
|---|---|
P(Disease) |
Prior probability — baseline disease prevalence |
P(Evidence\|Disease) |
Sensitivity — how often evidence appears given disease |
P(Evidence\|No Disease) |
False positive rate |
P(Disease\|Evidence) |
Posterior — updated probability after new evidence |
The system accepts height (cm) and weight (kg) to compute BMI, which adjusts risk estimates:
BMI = weight (kg) / (height in meters)²
| BMI Range | Category |
|---|---|
| Below 18.5 | Underweight |
| 18.5 – 24.9 | Normal |
| 25 – 29.9 | Overweight |
| 30+ | Obese |
Disease-prediction/
├── run.py # App entry point
├── dashboard.py # Streamlit analytics dashboard
├── requirements.txt # Python dependencies
├── hospital_data.csv # Bayesian stats (generated by pipeline)
├── data/
│ ├── raw/ # Original datasets (git-ignored)
│ ├── cleaned/
│ │ └── hospital_data_cleaned.csv
│ └── preprocess.py # Data pipeline script
├── backend/
│ ├── routes/ # Flask routes (auth, ML, calculator)
│ ├── models/ # Database & ML models
│ ├── utils/ # Bayesian calculator & AI helpers
│ ├── static/ # JS & CSS
│ └── templates/ # HTML templates
├── README.md
└── LICENSE
| Disease | Dataset | Source |
|---|---|---|
| Heart Disease | UCI Heart Disease Dataset | UCI Repository |
| Diabetes | Pima Indians Diabetes Dataset | Kaggle |
| Breast Cancer | Breast Cancer Wisconsin | UCI Repository |
To regenerate hospital_data.csv from raw datasets:
python data/preprocess.py
Raw dataset files are not committed to this repo. Download them from the links above and place them in
data/raw/.
| Model | Dataset | Conditions |
|---|---|---|
| Eye Disease CNN | Eye Diseases Classification (Kaggle) | Glaucoma, Diabetic Retinopathy, Cataract, Normal |
| Skin Disease CNN | Skin Diseases Image Dataset (Kaggle) | Melanoma, Eczema, Psoriasis, and 7 others |
The CNN architecture is based on ResNet, inspired by He et al. (2016) — Deep Residual Learning for Image Recognition.
AI recommendations not working?
GEMINI_API_KEY is set correctlyApp not starting?
python --versionpip install -r requirements.txtContributions are warmly welcome! Here's how to get started:
git checkout -b feature/your-feature-namegit commit -m "Add: your meaningful message"git push origin feature/your-feature-namePlease read CONTRIBUTING.md and CODE_OF_CONDUCT.md before contributing.
This project is licensed under the MIT License — see the LICENSE file for details.
Created and maintained by Alivia Hossain
⭐ If you find this project useful, consider giving it a star!
$ claude mcp add Disease-prediction \
-- python -m otcore.mcp_server <graph>