The XGBoost MOS "bias correction" sitting on top of Chronos-2 wasn't
earning its keep:
- The monthly retrain (scripts/retrain_mos.py) wrote to models/mos_*.json,
which the live pipeline never loaded — it reads models/price_model.joblib
via ChronosXGBoostForecaster.load(). The retrain has been a silent no-op
since it was written.
- The in-pipeline _train_mos path trained on synthetic data every run
(generate_training_data), against residuals that were structurally OK
but contributed no real accumulated learning. Fresh model per run, 20
samples minimum, no eval gate.
- The retrain script itself had three correctness bugs (cartesian join,
current_price = actual label leak, no promotion gate) — all moot now
since the script is deleted.
Chronos-2 is the honest ML story: a foundation model producing zero-shot
probabilistic forecasts with quantile-native confidence intervals. The
XGBoost standalone model remains as a fallback when Chronos fails to
load or a pair has insuffic…
Phase 11's frontend work (tour, pages, format helpers) was React-side
only. The Vercel serverless endpoints under frontend/api/ were all
still India-specific, so the live site at
https://crop-pricing.jeff-levine.com was mixing:
- hardcoded Tamil Nadu mandi list at /api/mandis
- India-only commodity/mandi name maps falling back to raw IDs on
Kenya rows at /api/market-prices and /api/price-forecast
- pre-migration India runs from Neon still being served by
/api/sell-recommendations
This commit moves every region-coupled lookup to a shared helper.
- frontend/api/_region.ts (NEW): getRegion() + per-region mandi
descriptors (11 Kenya, 15 India), commodity name maps, featured
farmer fallbacks, data-source provenance list, and
isRegionMandi() / isRegionFarmer() prefix filters for Neon queries.
Mandi IDs distinguish by prefix (MKT-* = Kenya, MND-* = India) so
filtering doesn't need a dedicated region column.
- mandis.ts: region-aware static list via getMandis().
- market-prices…
Add monthly MOS retrain from accumulated Neon data
- scripts/retrain_mos.py: pulls prediction-vs-actual pairs from Neon,
builds training features, retrains XGBoost MOS correction models
- POST /api/pipeline/retrain-mos endpoint for triggering from GH Action
- Weekly GH Action retrains on 4th Monday of each month (or manual)
- Model improves over time as more real Agmarknet data accumulates
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>