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 β¦