Browse by type
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
Click the preview to play the demo video (MP4, 1080p, with sound).
⚠️ 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 (data/hospital_data.csv) |
Option 1 — View Online (instant, no setup) 👉 https://disease-prediction-nwnu.onrender.com
Option 2 — Run Locally (no configuration needed)
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/
That's it. You don't need a .env file to run locally. python run.py starts in development mode, generates a temporary SECRET_KEY, and turns off the AI features until you add a GEMINI_API_KEY (see step 4).
| Want to… | Command |
|---|---|
| Use a different port | PORT=8000 python run.py (PowerShell: $env:PORT=8000; python run.py) |
| Open the Streamlit analytics dashboard | streamlit run dashboard/dashboard.py → http://127.0.0.1:8501 |
| Run with Docker instead | docker compose up --build (needs a .env; see below) |
python -m venv venv
source venv/bin/activate # macOS / Linux
venv\Scripts\activate # Windows
pip install -r requirements.txt
You can skip this step for a quick local run. Create a .env when you want AI features, a persistent SECRET_KEY (so you stay logged in across restarts), or a Docker/production deployment.
Create your local .env by copying the provided template:
cp .env.example .env # macOS / Linux
copy .env.example .env # Windows (cmd)
Copy-Item .env.example .env # Windows (PowerShell)
Then open .env and fill in the values. At minimum, generate a fresh SECRET_KEY:
python -c "import secrets; print(secrets.token_hex(32))"
Paste the output into the SECRET_KEY= line. The default SECRET_KEY in .env.example is public — never reuse it.
Get a free API key from Google AI Studio, then set GEMINI_API_KEY in your .env:
GEMINI_API_KEY=your_key_here
Alternatively, export it as an environment variable:
export GEMINI_API_KEY=your_key_here # macOS / Linux
set GEMINI_API_KEY=your_key_here # Windows
python run.py
The app is served at http://127.0.0.1:5001/. Set PORT or HOST to change where it listens. To run the Flask app and the Streamlit dashboard together the way production does, use bash scripts/start.sh.
The application can be deployed to Google Cloud Run.
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 (python run.py)
├── requirements.txt # Python dependencies
├── .env.example # Environment variable template
├── Dockerfile, docker-compose.yml # Container / deployment config
├── backend/ # Flask application
│ ├── routes/ # Flask routes (auth, ML, calculator)
│ ├── models/ # Database & ML models
│ ├── utils/ # Bayesian calculator & AI helpers
│ ├── static/ # JS, CSS & images
│ ├── templates/ # HTML templates
│ └── tests/ # Backend test suite (run in CI)
├── dashboard/
│ └── dashboard.py # Streamlit analytics dashboard
├── data/ # All datasets
│ ├── hospital_data.csv # Bayesian stats used by the app
│ ├── hospital_data.example.csv # Format template
│ ├── raw/ # Source datasets
│ └── cleaned/ # Pipeline output
├── database/ # Your local data: accounts & history (git-ignored)
├── docs/ # All documentation (setup, deployment, security, …)
├── scripts/ # Data pipeline & maintenance scripts
│ ├── fetch_datasets.py # Download raw datasets
│ ├── preprocess.py # Rebuild data/hospital_data.csv
│ ├── seed_diseases.py # Seed the diseases DB table
│ └── start.sh # Run Flask + Streamlit together
├── tests/ # Additional tests
├── README.md
└── LICENSE
You can run every script from any directory, for example python scripts/preprocess.py.
| 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 data/hospital_data.csv from the raw datasets in data/raw/:
python scripts/preprocess.py
To re-download the raw datasets, run
pip install ucimlrepoand thenpython scripts/fetch_datasets.py.
| 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.
All app data is stored in one dedicated database file:
database/
├── disease_prediction.db # accounts, password hashes, profiles, prediction history,
│ # and Streamlit dashboard history
└── .secret_key # local dev key that keeps you signed in across restarts
database/ folder.backend/site.db and JSON history are imported automatically the first time you start the app. The old files are left in place.docker compose mounts ./database into the container, so data survives rebuilds.DATABASE_DIR=/path/to/folder, or DATABASE_URL=postgresql://… to use PostgreSQL or MySQL instead.AI recommendations not working?
GEMINI_API_KEY is set correctlyApp not starting?
python --versionpip install -r requirements.txtpython run.pyPORT=8000 python run.pySECRET_KEY environment variable is required? Your .env or shell sets FLASK_ENV=production. For local work, change it to FLASK_ENV=development or set a SECRET_KEY.Contributions 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. More guides (setup, deployment, Gemini, security, privacy) are in docs/.
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>