Can you accurately forecast weekly market prices for maize in Kenya?. ccurate forecasts will help farmers time their sales effectively, increase earnings, and strengthen agriBORA’s integrated storage, credit, and market intelligence service to East African farmers.
# ML-Commodity-Forecasting
# AgriBORA Maize Price Forecasting Challenge - 3rd Place Solution
## 📋 Executive Summary
This repository contains the **3rd place winning solution** for the Zindi agriBORA Commodity Price Forecasting Challenge. The solution implements a sophisticated machine learning pipeline for multi-step ahead time series forecasting of weekly maize wholesale prices across five Kenyan counties.
**Achievement:** 3rd place ranking through robust feature engineering, Bayesian hyperparameter optimization, and ensemble modeling techniques with composite score (50% RMSE + 50% MAE).
---
## 🔄 Notebook Workflow Summary
The **Agribora_modelling.ipynb** implements a comprehensive 14-section machine learning pipeline:
### Workflow Overview
```
SECTION 1-2: ENVIRONMENT & DATA LOADING
├─ Setup Python environment, import libraries
├─ Load raw data from 4 CSV sources
└─ Display data summaries & availability
SECTION 3: EXPLORATORY DATA ANALYSIS (EDA)
├─ Examine data structure and distributions
├─ Identify date ranges and county coverage
└─ Assess data quality and completeness
SECTION 4: DATA PREPROCESSING & CLEANING
├─ Aggregate daily prices to weekly
├─ Consolidate multiple data sources
├─ Filter target counties and validate
└─ Handle missing values strategically
SECTION 5: PANEL DATA CONSTRUCTION
├─ Create complete county × week grid
├─ Merge price data with external features
├─ Forward/backward fill missing values
└─ Drop incomplete records
SECTION 6: FEATURE ENGINEERING
├─ Generate 60+ features:
│ ├─ Temporal (week, month, day)
│ ├─ Seasonal (Fourier sin/cos)
│ ├─ Lagged prices (1W, 2W, 4W, 8W, 12W)
│ ├─ Momentum indicators (rate of change)
│ ├─ Volatility (rolling std dev)
│ ├─ Trends (rolling means, ratios)
│ ├─ Transformations (log prices)
│ └─ External feature lags (FX, CPI)
└─ Fill remaining NaN values intelligently
SECTION 7: TRAIN-TEST SPLIT
├─ Time-series aware split (last 2 weeks = test)
├─ Prepare feature matrix (X) and target (y)
├─ T …