Smart, data-driven inflation forecasting for Kenya powered by machine learning, sleek visuals, and a little genius.
# Commodity Price Forecasting Using Machine Learning
## Project Overview
This project predicts the **next-month average prices** of key commodities in Kenya, using historical data, seasonality trends, and lag-based features. The goal is to provide **actionable forecasts** for stakeholders such as businesses, government agencies, and supply chain managers, helping them make informed procurement, pricing, and risk management decisions.
The modeling approach focuses on:
- High-quality **real-world price data** across multiple commodity types (food, energy, utilities, rent, etc.)
- Awareness of **seasonality and market cycles**
- **Unit normalization**, e.g., electricity in kWh
- Explainable and interpretable machine learning models, primarily **Random Forest**, with metrics to track predictive accuracy
## Project Objectives
1. **Forecast Commodity Prices**
Predict the next month’s average price for each commodity variant, enabling better planning and cost management.
2. **Understand Price Dynamics**
Quantify short-term and seasonal trends, volatility, and persistence using lag, rolling averages, and change features.
3. **Support Decision-Making**
Generate actionable insights for businesses, policymakers, and investors using interpretable ML models.
4. **Provide Robust and Scalable Tools**
Implement per-commodity modeling pipelines that scale to hundreds of items with automated evaluation and reporting.
## Data
The project uses historical commodity prices from 2012–2025. The dataset includes:
| Column | Description |
|--------|-------------|
| `commodity_name` | Name of the commodity (e.g., Tomatoes, Electricity) |
| `units_of_measure` | Unit for the price (e.g., kg, litre, 50 KWh) |
| `current_average_price` | Monthly average market price |
| `year`, `month`, `quarter` | Time-based features for seasonality capture |
| `price_lag_1`, `price_lag_2`, `price_lag_3` | Lag features for last 1–3 months |
| `price_rolling_mean_3`, `price_rolling_std_3` | Rollin …