Logo Lanfrica

Ferinmtk/kenya-crop-price-forecast

Domain:

agriculture

Record type:

software
Creator:
Fer
Host:
Monthly price forecasting for Kenyan crops. Full ML pipeline with leakage tests and honest baseline comparison. Kenya Crop Price Forecast Monthly price forecasting for Kenyan agricultural commodities. A full ML pipeline — ingest, clean, engineer, train, evaluate, serve — that reports what it can't do as clearly as what it can. --- ## What it does Farmers and traders decide when to sell based on where they think prices are going. This forecasts monthly prices per commodity per county, with an uncertainty band that widens honestly as the horizon extends. ``` date commodity county predicted_price lower upper months_ahead confidence 2026-06-01 Maize Nakuru 6588.98 5730.74 7447.22 1 medium 2026-07-01 Maize Nakuru 6270.47 5056.74 7484.20 2 medium 2026-08-01 Maize Nakuru 6082.63 4596.12 7569.14 3 low ``` Prices fall into August because that's the harvest. The model learned that from the data, not from a rule. ## The result, stated plainly Every model is scored against three naive baselines. Here is the actual output: | model | MAE | MAPE | beats baseline | |---|---|---|---| | **ridge** | **310** | **3.6%** | **yes, by 25.2%** | | random forest | 390 | 4.4% | yes, by 5.9% | | *baseline: last month* | *414* | *5.1%* | — | | gradient boosting | 440 | 5.4% | **no, 6.2% worse** | | *baseline: 3-month average* | *635* | *8.1%* | — | | *baseline: same month last year* | *815* | *8.3%* | — | Two things worth noticing. Ridge — the simplest model — wins. And gradient boosting, the one that sounds most impressive, loses to predicting last month's price. Both facts are printed by `scripts/train.py` on every run. **Why baselines matter.** "MAPE 3.6%" sounds good in isolation and means nothing. Prices are autocorrelated: last month's price is already a strong prediction of this month's. A model that can't beat it has learned nothing worth deploying. Most portfolio forecasting projects report a metric without a baseline, and the metric is unfalsifiable. ## Quick start ```bash git …