Skip to content

Vidheendu/Disease-prediction

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

315 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

๐Ÿง  Disease Prediction System

An ML-powered, educational web application that demonstrates how machine learning, Bayesian probability, and AI can be used to estimate disease likelihood based on symptoms and diagnostic test results.

This project is designed to make diagnostic reasoning transparent, intuitive, and interactive - especially for students, researchers, and developers exploring medical ML concepts.


โš ๏ธ Disclaimer

Educational Use Only

This project is intended strictly for learning, research, and demonstration purposes.
It is not a medical tool and must not be used for real-world diagnosis or treatment decisions.

Always consult a qualified healthcare professional for medical advice.


โœจ Core Highlights

  • ๐Ÿ”ฌ Combines Machine Learning + Bayesian Inference
  • ๐Ÿ“Š Visual comparison of prior vs posterior probabilities
  • ๐Ÿค– AI-powered explanations & next-step recommendations
  • ๐ŸŒ Multi-language support (English, Hindi, Gujarati, Tamil)
  • ๐ŸŒ™ Dark mode for better accessibility
  • ๐Ÿ“˜ Beginner-friendly educational explanations

๐Ÿ“‘ Table of Contents


๐Ÿš€ Quick Start (30 seconds)

git clone https://github.com/aliviahossain/Disease-prediction.git
cd Disease-prediction
pip install -r requirements.txt
python run.py

Open in your browser: ๐Ÿ‘‰ http://127.0.0.1:5001/

Thatโ€™s it ๐ŸŽ‰

๐Ÿ“Œ Key Features

๐Ÿ“˜ Educational Features

  • Clear explanations of Prior, Likelihood, and Posterior Probability
  • Step-by-step visualization of Bayesโ€™ Theorem
  • Interactive probability sliders for experimentation
  • Built-in glossary and help section

๐Ÿค– ML Features

  • Symptom-based disease prediction
  • Disease selection with predefined symptom sets
  • ML-generated probability scores
  • Risk categorization (Low / Medium / High)

๐Ÿง  AI Features

  • AI-powered interpretation of probability results
  • Suggested next steps (consultation, testing, lifestyle review)
  • Multi-language AI output:
    • ๐Ÿ‡ฌ๐Ÿ‡ง English
    • ๐Ÿ‡ฎ๐Ÿ‡ณ Hindi
    • ๐Ÿ‡ฎ๐Ÿ‡ณ Gujarati
    • ๐Ÿ‡ฎ๐Ÿ‡ณ Tamil

Powered by Google Gemini API

๐Ÿ—‚๏ธ Project Structure

Disease-prediction/
โ”œโ”€โ”€ run.py                      # Application entry point
โ”œโ”€โ”€ dashboard.py                # Streamlit interactive dashboard
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ hospital_data.csv           # Sample statistical data
โ”œโ”€โ”€ 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
โ””โ”€โ”€ Scalability_report.txt

๐Ÿ› ๏ธ Getting Started (Detailed)

1๏ธโƒฃ Create a Virtual Environment (Recommended)

python -m venv venv
source venv/bin/activate   # macOS/Linux
venv\Scripts\activate      # Windows

2๏ธโƒฃ Install Dependencies

pip install -r requirements.txt

3๏ธโƒฃ Run the Application

python run.py

๐Ÿค– Using AI-Powered Recommendations

Enable Gemini AI (Optional but Recommended)

Step 1: Get an API Key

Get your free API key from Google AI Studio

Step 2: Configure the API Key

Using .env file (recommended):

GEMINI_API_KEY=your_api_key_here

Or via environment variable:

export GEMINI_API_KEY=your_api_key_here   # macOS/Linux

How It Works

  1. Calculate disease probability
  2. Choose a language ๐ŸŒ
  3. Click โ€œGet AI Recommendationsโ€
  4. Receive:
    • Probability interpretation
    • Suggested next actions
    • Medical disclaimers

๐Ÿงฎ Bayesโ€™ Theorem Explained

Bayesโ€™ Theorem updates the probability of a condition after observing new evidence, such as a test result.

Formula:

P(A|B) = [P(B|A) ร— P(A)] / [P(B|A) ร— P(A) + P(B|ยฌA) ร— P(ยฌA)]

Where:

  • P(A) โ†’ Prior probability
  • P(B|A) โ†’ Sensitivity
  • P(B|ยฌA) โ†’ False positive rate
  • P(A|B) โ†’ Posterior probability

This project visualizes this shift clearly using charts and explanations.

๐Ÿ”ง Troubleshooting

AI Not Working?

  • Ensure GEMINI_API_KEY is set
  • Restart the application
  • Check internet connectivity
  • Verify API quota availability

App Not Starting?

  • Confirm Python โ‰ฅ 3.9
  • Reinstall dependencies
  • Activate virtual environment

๐Ÿ”’ Privacy & Data Handling

All image processing and probability calculations are performed locally on the userโ€™s machine.
No images, symptoms, or personal data are uploaded, stored, or shared externally by default.

๐Ÿง  Model Architecture

The eye-disease image classification model is based on a deep convolutional neural network using a ResNet architecture inspired by:

He, K., Zhang, X., Ren, S., & Sun, J. (2016).
Deep Residual Learning for Image Recognition. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR).

๐Ÿ“Š Dataset Sources

The eye-disease image prediction model was trained using the following publicly available dataset from Kaggle:

This dataset includes labeled images for:

  • Normal eyes
  • Glaucoma
  • Diabetic Retinopathy
  • Cataract

The skin-disease image prediction model was trained using the following publicly available dataset from Kaggle:

This dataset includes labeled images for the following conditions:

  • Atopic Dermatitis
  • Basal Cell Carcinoma
  • Benign Keratosis-like Lesions
  • Eczema
  • Melanocytic Nevi
  • Melanoma
  • Psoriasis
  • Seborrheic Keratoses and other Benign Tumors
  • Tinea Ringworm, Candidiasis, and other Fungal Infections
  • Warts, Molluscum, and other Viral Infections

All dataset credits belong to their respective authors and contributors. This project does not claim ownership of the dataset. Please refer to the dataset page for licensing and usage terms.

  • All computations run locally
  • No personal data is stored or transmitted
  • AI requests only include probability values (no user identity)

๐Ÿ“Š Dataset & Model

Dataset

  • Eye Diseases Classification Dataset (Kaggle)
    • Normal
    • Glaucoma
    • Diabetic Retinopathy
    • Cataract

Model Architecture

  • CNN based on ResNet
  • Inspired by He et al., 2016 - Deep Residual Learning

๐Ÿ“œ License

This project is licensed under the MIT License. See the LICENSE file for details.

๐Ÿ™Œ Acknowledgements

Created and maintained by Alivia Hossain.

Contributions are welcome, feel free to open issues or pull requests.

โญ If you find this project useful, consider giving it a star!

About

A probability calculator using Baye's Theorem to estimate survival chances of a disease based on past hospital data.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HTML 44.6%
  • Python 43.0%
  • JavaScript 6.9%
  • CSS 5.3%
  • Other 0.2%