Food Price Prediction Model and API
# East Africa Food Price Prediction
An end-to-end ML project predicting maize prices at Owino market, Kampala, Uganda — from raw WFP data to a production FastAPI deployed on HuggingFace.
**The honest finding:** A 3-month rolling average (MAE 196 UGX/kg) beats every ML model we tried. This README documents why, and what we built along the way.
---
## Results
| Model | Train Rows | MAE (UGX/kg) | Notes |
|-------|-----------|-------------|-------|
| Naive baseline (rolling mean 3) | — | **196** | Hard to beat |
| RF v6 — EA prices + feature eng. | 143 | **216** | Best honest ML · deployed |
| RF v4 — global maize + FX | 155 | 223 | No CPI dependency |
| RF v3 — maize CPI (leaky) | 65 | 224 | Uses same-month CPI — invalid in production |
| RF v3 — CPI lag-1 (honest) | 65 | 268 | What v3 actually does in production |
| RF v5 — real prices (deflated) | 65 | 263 | Deflation approach |
| Prophet | — | 1,169 | Trend extrapolation fails on 2024 correction |
Test set: January 2024 – April 2025 (16 months). See MODEL_BENCHMARKS.md for full details.
---
## Structure
```
food_prices_model/
01_exploration.ipynb # EDA — price distributions, seasonality
02_feature_engineering.ipynb
03_model_training.ipynb # v1 baseline
04_cpi_feature.ipynb # broad food CPI experiment
05_retrain_full.ipynb # v3 — maize-specific CPI + leakage test
06_prophet.ipynb # Prophet experiment (MAE 1,169)
07_cpi_backfill.ipynb # Attempted UBOS CPI backfill to 2006
08_retrain_v4.ipynb # v4 — World Bank global maize + FX
09_retrain_v5.ipynb # v5 — real prices (CPI deflation)
10_retrain_v6.ipynb # v6 — EA regional prices + feature engineering
food_prices_api/
main.py # FastAPI — loads v6, fetches EA/global maize + FX
features.py # Feature computation (12-month window)
models.py # Pydantic request/response models
```
---
## Data
All datasets published to HuggingFace:
- **Prices:** ` …