AI/ML model that predicts next-period tomato & onion market prices in Kano, Nigeria, using historical price trends, feature engineering, and Linear Regression/Random Forest. Built for the 3MTT NextGen AI & ML Cohort (Brief AI-07) — feeds into the Fursa community platform.
# AI-07 — Market Price Predictor (Tomato / Onion)
**3MTT NextGen AI & ML Cohort — Individual Capstone Submission**
**Fellow:** Abubakar Jibrin Gunda
**Fellow ID:** FE/25/2523358832
**Brief ID:** AI-07
## Problem
Traders and buyers of perishable produce (tomato, onion) in Nigerian markets face volatile day-to-day prices, making it hard to plan purchases, sales, or storage. This project builds a machine learning model that predicts the next-period market price for tomato and onion in Kano Central Market, giving users a data-backed reference point instead of guesswork.
## What Was Built (MVP)
- Historical daily price data for tomato and onion (Kano Central Market)
- Feature engineering: lag prices, rolling averages/volatility, day-of-week, market-day flags, calendar features
- Two models trained and compared per commodity: Linear Regression and Random Forest
- Best model selected automatically per commodity based on test-set MAE
- 7-day forward price forecast with trend chart
- Evaluation via MAE, RMSE, and MAPE on a held-out 60-day test period
## Results Summary
| Commodity | Best Model | MAE (₦) | RMSE (₦) | MAPE (%) |
|---|---|---|---|---|
| Tomato | Linear Regression | 28.12 | 33.47 | 3.18 |
| Onion | Linear Regression | 10.15 | 12.89 | 1.88 |
Both models achieve under 3.5% mean absolute percentage error on unseen test data — a strong result for a beginner-scoped MVP.
## A Note on the Data
Live, market-level historical price feeds (WFP VAM Nigeria, HDX, World Bank Real-Time Food Prices) were identified as good future data sources but were not reachable for direct download from this project's development environment. The dataset used here (`data/kano_tomato_onion_prices.csv`) is therefore a **simulated series, calibrated to real, publicly reported reference prices** for Kano State:
- Tomato ≈ ₦386/kg (NBS, Aug 2023, via Statista)
- Onion ≈ ₦300/kg (NBS, Aug 2023, via Statista)
Realistic inflationary drift, seasonality (tomato is more seasonal due to peris …