Skip to content

Latest commit

Β 

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🩺 Diabetes Risk Diagnostic Tool

A machine learning-powered web application that estimates diabetes risk from clinical health metrics, built with a FastAPI backend and a Next.js frontend. Originally a Streamlit app, rebuilt into a full separate backend/frontend architecture.


πŸš€ Live Demo

Try the live app


✨ Features

  • AI-powered predictions β€” a Random Forest Classifier (scikit-learn) trained on the Pima Indians Diabetes Database estimates risk from 8 clinical inputs.
  • Population comparison β€” each input shows the dataset's actual average alongside your entry, for context.
  • Session history β€” every check you run stays visible in a running list for the current session.
  • Downloadable report β€” generates a plain-text summary of your inputs and result.
  • Location-aware doctor recommendation β€” if a result reads High Risk, a button finds nearby endocrinologists (Oladoc in Pakistan, Google Maps elsewhere), based on your browser's location.
  • Animated ECG pulse visual β€” a live-drawing heartbeat-style line that changes color depending on the result.

πŸ› οΈ Tech Stack

  • Backend: FastAPI, scikit-learn, pandas, deployed on Render
  • Frontend: Next.js (App Router, JavaScript, Tailwind CSS), deployed on Vercel
  • Model: Random Forest Classifier, ~80.5% accuracy, trained on the Pima Indians Diabetes Database

πŸš€ Installation & Local Setup

Backend

cd backend
python -m venv venv
venv\Scripts\Activate.ps1
pip install -r requirements.txt
uvicorn app.main:app --reload

Runs at http://127.0.0.1:8000.

Frontend

cd frontend
npm install
npm run dev

Runs at http://localhost:3000. Requires a .env.local file containing:

NEXT_PUBLIC_API_URL=http://127.0.0.1:8000

πŸ“‚ Project Structure

DiabetesDetector/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py          # FastAPI app: loads model, exposes /predict
β”‚   β”‚   └── model.pkl        # Pre-trained Random Forest model
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ layout.js        # Fonts, metadata
β”‚   β”‚   β”œβ”€β”€ page.js          # Main UI: form, pulse animation, results
β”‚   β”‚   └── globals.css      # Design tokens (colors, fonts)
β”‚   └── package.json
β”œβ”€β”€ Notebook/
β”‚   β”œβ”€β”€ explore.ipynb        # Data analysis & model training
β”‚   └── model.pkl
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ confusion_matrix.png
β”‚   └── DiabetesDetector.gif
└── model.py                 # Alternate training script (Pipeline + scaler)

🧠 Model Insights

The model achieves ~80.5% accuracy. Confusion matrix on held-out test data:

Confusion Matrix

The model is particularly strong at correctly identifying healthy patients, with a focus on minimizing false negatives.


πŸ‘€ Author

Syed Ali Faraz β€” GitHub Profile

If you found this tool insightful, please give the repository a ⭐!

About

🩺 Diabetes Detector: An ML diagnostic tool using a Random Forest Classifier to predict diabetes risk. FastAPI backend + Next.js frontend, with real-time predictions, population comparisons, and location-aware doctor recommendations.

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages