Early detection of health risk is one of the most impactful applications of machine learning in healthcare. This project builds a complete, production-ready supervised learning pipeline that predicts whether a patient is Healthy (0) or At-Risk (1) based on their physiological vitals, lifestyle habits, and medical history.
The pipeline goes beyond a simple notebook — the best performing model (XGBoost, AUC = 0.989) is deployed as a live interactive web application accessible to anyone.
Key Technical Skills Demonstrated: Feature Engineering · EDA · Hyperparameter Tuning (GridSearchCV) · Model Evaluation · Model Serialization (Joblib) · Streamlit Deployment
Try the deployed app here: https://health-classifier-kp.streamlit.app/
Input any patient's vitals, lifestyle data, and medical history and the XGBoost model will return a real-time health risk classification with a confidence score.
The ROC Curve directly shows how well each classifier distinguishes between healthy and at-risk patients across all thresholds. XGBoost achieved the highest AUC of 0.989.
| Model | AUC Score | Notes |
|---|---|---|
| Logistic Regression | 0.888 | Baseline model |
| Random Forest | 0.985 | Tuned with GridSearchCV |
| XGBoost | 0.989 | Selected for deployment |
Understanding which features drive predictions is critical for clinical interpretability. The chart below shows the relative feature importance scores extracted directly from the trained XGBoost model.
Key Insight: BMI and Cholesterol are the single strongest predictors of health risk in this dataset, followed by Stress Level and Glucose Level. This aligns strongly with established medical literature on lifestyle-driven chronic disease risk.
Health-Risk-Classifier-ML/
│
├── 📓 Health_Risk_Classification_Enhanced.ipynb ← Full EDA + Model Training
├── 🌐 app.py ← Streamlit Web Application
├── 🏋️ train_model.py ← Model Training & Serialization Script
│
├── 📦 xgboost_health_model.pkl ← Serialized XGBoost Model
├── 📦 model_columns.pkl ← Feature Column Order (for safe inference)
├── 📄 novagen_dataset.csv ← Dataset (9,500+ patient records, 22 features)
│
└── 📋 requirements.txt ← Python dependencies
- Investigated distributions of all 22 features using histograms and KDE plots.
- Analyzed correlation between features and the target variable using a heatmap.
- Detected and treated class imbalance and missing values.
- One-hot encoded categorical variables (
Diet_Type,Blood_Group). - Standardized numerical features for Logistic Regression compatibility.
- Preserved original scale for tree-based models (RF, XGBoost).
Three classifiers were trained and evaluated:
| Model | Strategy |
|---|---|
| Logistic Regression | Baseline, C tuned via GridSearchCV |
| Random Forest | n_estimators, max_depth, min_samples_split tuned |
| XGBoost | learning_rate, max_depth, n_estimators tuned |
Models were compared using AUC-ROC, F1-Score, Precision, and Recall on a held-out 20% test set. XGBoost was the clear winner and selected for web deployment.
1. Clone the repository:
git clone https://github.com/kabirpatil12676/Health-Risk-Classifier-ML.git
cd Health-Risk-Classifier-ML2. Install dependencies:
pip install -r requirements.txt3. View the Notebook (EDA + Training):
jupyter notebook "Health_Risk_Classification_Enhanced.ipynb"4. Launch the Streamlit Web App:
streamlit run app.pyThe novagen_dataset.csv contains 9,500+ patient records across 22 features including:
| Category | Features |
|---|---|
| Physiological | Age, BMI, Blood Pressure, Cholesterol, Glucose Level, Heart Rate |
| Lifestyle | Sleep Hours, Exercise Hours, Water Intake, Stress Level, Smoking, Alcohol |
| Dietary | Diet Quality, Diet Type (Vegan/Vegetarian) |
| Medical | Family Medical History, Mental Health, Allergies, Blood Group |
Target Variable: 0 = Healthy, 1 = At-Risk
Kabir Patil

