This repository contains a highly optimized, end-to-end Machine Learning pipeline for the Kaggle Playground Series (Season 6, Episode 7): Predicting Student Health Risk.
The goal of this competition is to accurately predict the health_condition of a student (e.g., at-risk, fit, unhealthy) based on their physical metrics and lifestyle choices. The evaluation metric for this competition is Balanced Accuracy.
- Dataset Augmentation: The competition data is synthetic, heavily inspired by the real-world College Student Health Behavior Dataset. To combat synthetic noise, we augment our training data by merging it with the original dataset, bringing the total training rows to ~740,000.
- Feature Engineering:
- Ordinal Encoding: Re-mapped ordered categories (e.g.,
sleep_qualityfrom poor/average/good to 0/1/2). - Interaction Features: Created custom metrics like
bmi_x_exerciseandsleep_score(Sleep Duration × Sleep Quality).
- Ordinal Encoding: Re-mapped ordered categories (e.g.,
- 5-Fold Cross-Validation Ensemble: We utilized a strict 5-fold Stratified K-Fold cross-validation strategy. Within each fold, we trained and ensembled two of the fastest and most robust gradient boosting frameworks: LightGBM and XGBoost.
- Prior Correction for Balanced Accuracy: The competition is evaluated on Balanced Accuracy, but the dataset suffers from extreme class imbalance (~86% of students are 'at-risk'). We applied a mathematical Prior Correction technique to the blended model probabilities, artificially re-weighting the predictions against the training class priors. This forces the model to directly optimize for Balanced Accuracy.
| Model / Pipeline | Public Leaderboard Score |
|---|---|
| Fast LightGBM Baseline | 0.94904 |
| Optimized 5-Fold Ensemble | 0.94789 |
(Note: While the fast baseline scored slightly higher on the Public Leaderboard (which only tests 20% of hidden data), the 5-Fold Ensemble with prior correction is mathematically more robust and designed to prevent overfitting on the final Private Leaderboard.)
final_solution.ipynb: The complete Jupyter Notebook containing the data loading, feature engineering, 5-fold ensemble loop, and prior correction logic. It is dynamically written to work effortlessly on local environments or Kaggle Cloud Kernels.- (Note: The CSV datasets are excluded from this repo via
.gitignoredue to size limits. You can download the data from the Kaggle competition page).
- Download the data from the Kaggle Competition.
- Download the Original Dataset.
- Place
train.csvandtest.csvin the root directory. - Place
student_health_dataset_50k.csvinoriginal_data/. - Run the
final_solution.ipynbnotebook from top to bottom.
Authored by shibomdas