AI-powered post-harvest loss prediction tool fot Ghanaian farmers
# 🌽 HarvestGuard Ghana
*AI-Powered Post-Harvest Loss Prediction for Ghanaian Farmers*
> Know When to Sell. Know Where to Sell. Lose Less.
## About
HarvestGuard Ghana is a machine learning web application that helps
Ghanaian smallholder farmers predict post-harvest crop losses and
find the best market to sell their produce across all 16 regions of Ghana.
Built for the *Ghana AI Innovation Challenge 2026* — Agriculture Focus Area.
## Problem
Ghana loses an estimated *$1.9 billion* annually to post-harvest losses.
Farmers lack real-time information on:
- How fast their crop is deteriorating
- Which market offers the best price
- How to store their produce properly
## Solution
HarvestGuard Ghana uses a *Random Forest ML model* (R²=0.9873) trained
on research-backed Ghanaian agricultural data to predict loss rates and
provide actionable market intelligence.
## Features
- Post-harvest loss prediction for Maize, Tomatoes, and Yam
- Market price comparison across all 16 regions of Ghana
- Risk alert system (High / Moderate / Low)
- Loss progression chart over 60 days
- Storage recommendations based on MoFA Ghana guidelines
- Collective impact calculator
## ML Model
- Algorithm: Random Forest Regressor (scikit-learn)
- Training samples: 3,000
- R² Score: 0.9873
- Mean Absolute Error: 2.58%
- Key feature: Storage method (82.9% importance)
## Data Sources
- Ministry of Food & Agriculture Ghana (MoFA) SRID
- Wongnaa et al. (2023) — Cogent Food & Agriculture
- FAO / FAOSTAT — Ghana Agricultural Statistics
- Selinawamucii.com (2025) — Ghana Retail Prices
- Esoko Ghana Market Price Index (2024)
- MoFA/NAFCO Guaranteed Farmgate Prices (Sep 2025)
## How to Run
```bash
pip install -r requirements.txt
python train_model.py
streamlit run app.py