Predicting undernourishment across 49 African countries with 10 ML algorithms + statistical models (OLS, mixed-effects, SHAP). World Bank data, Python. A lesson in honest cross-validation.
# Predicting Undernourishment in Africa, 10 ML Algorithms + Statistical Models
A machine-learning and statistical study of **food insecurity (undernourishment)**
across **49 African countries (2001-2023)**, built in Python from World Bank data.
It compares **ten ML algorithms** and backs the findings with classical
**inferential statistics** (regression with full inference, VIF, and a
mixed-effects panel model).
> **Headline insight (a lesson in honest evaluation):** with ordinary random
> cross-validation the best model looks excellent (R² ≈ 0.98), but that is
> leakage, because the same country appears in both train and test. Under
> **country-held-out (GroupKFold)** validation, R² drops to **~0.17**: predicting
> undernourishment for a country the model has never seen is genuinely hard,
> because levels are persistent and country-specific.
---
## 🔬 What the project does
**Machine learning, 10 algorithms compared**
Linear Regression, Ridge, Lasso, ElasticNet, K-Nearest Neighbors, SVR (RBF),
Decision Tree, Random Forest, Gradient Boosting, and Extra Trees, each evaluated
under **two validation designs** (random vs. country-grouped) to expose data
leakage, with **SHAP** explaining the best model.
**Statistics to support the findings**
- **Correlation analysis** of every determinant with undernourishment (with significance).
- **OLS multiple regression** with standardised coefficients, 95% CIs, p-values and a **VIF** multicollinearity check.
- **Mixed-effects panel model** (random intercept by country), the appropriate model for repeated country observations.
## 🔑 Key findings
- **Income is the dominant correlate**: higher GDP per capita is strongly associated with lower undernourishment (r = -0.55).
- **Water access, sanitation and health spending** are also strongly protective (r ≈ -0.5).
- **Higher fertility and agricultural employment** are associated with *more* undernourishment.
- These directions are consistent across the correlation, OLS and mixed-ef …