YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
- Coffee Health Predictor: Advanced Modeling of Sleep and Stress
- 1. Executive Summary and Final Model Declaration
- Part 2: Data Analysis, Cleaning, and Preparation
- Part 3: Define and Train a Baseline Model
- Part 4: Feature Engineering (Advanced)
- Part 5: Train and Evaluate Three Improved Models (Regression)
- Part 7: Target Reframing (Regression-to-Classification)
- Part 8: Train & Eval Classification Models
- 1. Executive Summary and Final Model Declaration
Coffee Health Predictor: Advanced Modeling of Sleep and Stress
1. Executive Summary and Final Model Declaration
This project implemented a complete ML pipeline on the Global Coffee Health Dataset (~10,000 records). The final models are selected based on optimal accuracy, simplicity, and ethical considerations for health risk identification.
| Model Task | Final Winner | Key Metric (R2 / F1) | Rationale |
|---|---|---|---|
| Regression (Sleep Hours) | Linear Regression (Baseline) | 0.8367 | Optimal accuracy achieved with maximum simplicity; FE did not yield improvement. |
| Classification (Health Risk) | Logistic Regression | 0.849 | Fastest, most interpretable, and achieved {Recall} = {1.00} on the critical risk class. |
Part 2: Data Analysis, Cleaning, and Preparation
The initial EDA revealed a weak negative correlation ( -0.19) between the primary numerical predictor ({Caffeine\mg}) and the target ({Sleep\Hours}), proving that prediction relied on complex, hidden factors.
- Cleaning Action: Imputed approx 60% missing values in the {Health\Issues} column with a new category, 'None', to preserve data integrity.
- Feature Engineering Insight: The high {R}^2 score was primarily driven by thesimple encoding of self-reported categorical features.

Part 3: Define and Train a Baseline Model
Feature Importance Insight
The Feature Importance analysis revealed that Sleep\Quality and Stress\Level were the dominant predictors in the baseline Linear Regression model.
- Visualization: The Feature Importance graph visually confirms that {Sleep\Quality} and {Stress\Level} coefficients dominate, while the numerical features have negligible impact.

Part 4: Feature Engineering (Advanced)
Applying Clustering (Unsupervised Learning)
Complex FE was performed to challenge the linear baseline and capture non-linear interactions, including the creation of the {Physical\Health\Cluster} feature.
- Health Profile Clustering (K-Means, K=4): A critical feature was generated based on {BMI}, {Heart\Rate}, and {Physical\Activity\Hours}.
- Interpretation: The clustering successfully segmented the population into four distinct health profiles (e.g., Cluster 0: High Risk/Sedentary and Cluster 1: Healthy/Athlete).
- Visualization: The PCA plot confirmed clear segmentation of the physiological profiles.

Part 5: Train and Evaluate Three Improved Models (Regression)
Evaluation Summary
The comparison showed that the complex FE features did not improve the accuracy of the Linear Regression baseline.
| Model | {R}^2 Score | {RMSE} (Hours) | Insight |
|---|---|---|---|
| LR Baseline (Winner) | {0.8367} | {0.4874} | Accuracy driven by simple categorical encoding. |
| Random Forest | 0.8346 | 0.4904 | Failed to find additional non-linear value. |
Conclusion
The Linear Regression Baseline was declared the winner; the sophisticated modeling was unable to justify its complexity by improving on the initial linear result.
Part 7: Target Reframing (Regression-to-Classification)
- Strategy:* The continuous {Sleep\Hours} variable was converted into three discrete classification classes (Suboptimal, Average, Optimal) using Quantile Binning (Quartiles).
- Critical Metric: Recall was confirmed as the primary metric for the subsequent classification task, as minimizing False Negatives (FN) (missing a critical health risk) is the central ethical goal (as per the conclusion of Part 6).
Part 8: Train & Eval Classification Models
A. Critical Recall Performance
- Classification Winner: Logistic Regression. Selected for its superior interpretability, speed, and identical macro performance ({F1} \approx 0.849).
- Critical Recall Performance: The model achieved a Recall of {1.00} for the critical Suboptimal Sleep (Class 0) category. This signifies that the model did not miss a single case in the highest risk category, perfectly fulfilling the primary ethical mandate.
- Visualization: The Confusion Matrix visually confirms False Negatives in the critical risk class.
