Skip to content

About

ML-powered health risk predictor — trained on 5,000 lifestyle records using Random Forest (83.4% accuracy) with a Flask web app for real-time predictions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Health Risk Prediction System

A full-stack web application that predicts health risk (High/Low) based on lifestyle and physical metrics using a trained Random Forest Classifier (88.3% accuracy).

Project Structure

health_risk_app/
├── app.py                  # Flask server (API + static file serving)
├── predict.py              # Prediction logic (loads saved model)
├── train_model.py          # Model training script (run once)
├── requirements.txt        # Python dependencies
├── Procfile                # For Heroku/Render deployment
├── Lifestyle_and_Health_Risk_Prediction_Synthetic_Dataset.csv
├── models/                 # Saved model artifacts (generated by train_model.py)
│   ├── rf_model.pkl
│   ├── scaler.pkl
│   ├── le_target.pkl
│   ├── professions.pkl
│   └── features.pkl
└── static/
    └── index.html          # Single-page frontend (Landing + Form + Results)

Features

  • Landing page — model stats, feature highlights
  • Assessment form — all 11 input features with smart BMI auto-calculation
  • Results page — risk score, gauge chart, factor breakdown, personalised suggestions
  • No login/signup required • No data stored

Local Setup

# 1. Install dependencies
pip install -r requirements.txt

# 2. Train the model (only needed once, or if you change the dataset)
python train_model.py

# 3. Run the server
python app.py
# → Open http://localhost:5000

Deploy to Render (Free)

  1. Push this folder to a GitHub repo
  2. Go to https://render.com → New Web Service
  3. Connect your repo
  4. Set Build Command: pip install -r requirements.txt && python train_model.py
  5. Set Start Command: gunicorn app:app
  6. Deploy!

Deploy to Railway

# Install Railway CLI, then:
railway login
railway init
railway up

Deploy to Heroku

heroku login
heroku create your-app-name
git push heroku main
heroku run python train_model.py

Model Details

Model Accuracy
Random Forest (100 trees, max_depth=5) 88.3%
Decision Tree ~82%
Naive Bayes ~78%

Input features: age, weight, height, BMI, sleep, exercise, sugar intake, smoking, alcohol, marital status, profession
Target: High Risk / Low Risk

About

ML-powered health risk predictor — trained on 5,000 lifestyle records using Random Forest (83.4% accuracy) with a Flask web app for real-time predictions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages