An interactive ML-powered decision-support tool for cocoa farmers and processors in West Africa. Predicts fermentation index from field conditions and recommends optimal fermentation duration.
# CocoaQuality – Fermentation Quality Predictor
> An interactive ML-powered decision-support tool for cocoa farmers and processors in West Africa. Predicts fermentation index from field conditions and recommends optimal fermentation duration.
**Developed as part of the Advanced Analytics for Agribusiness course, MSc in Agribusiness & Innovation, UM6P.**
---
## Live Demo
Launch App on Streamlit Cloud
---
## Problem Statement
Cocoa fermentation is the most critical post-harvest step determining bean quality and farmer income. Poor fermentation — either under or over — directly reduces the market grade and price received. Farmers in Nigeria, Ghana, and Côte d'Ivoire often rely on experience alone, with no quantitative tool to guide decisions.
This app provides a data-driven recommendation engine that tells farmers:
- What quality grade their current batch will achieve
- Exactly when to stop fermentation for maximum value
- How much revenue they are leaving on the table vs the optimal scenario
---
## Features
| Feature | Description |
|---|---|
| Live weather fetch | Auto-fills temperature and humidity from any West African city via Open-Meteo API (no key required) |
| Animated quality curve | Shows predicted fermentation index across days 2–8 with uncertainty band |
| Optimal day marker | Identifies the peak quality day for current conditions |
| Revenue calculator | Converts quality grade to CFA/kg price and computes batch value vs optimal |
| West Africa heatmap | Choropleth map of fermentation quality potential by country |
| Model comparison | RMSE / MAE / R² for all 3 models with feature importance chart |
---
## ML Pipeline
### Models compared
| Model | RMSE | R² |
|---|---|---|
| Linear Regression | ~0.14 | ~0.92 |
| Random Forest | ~0.12 | ~0.95 |
| Gradient Boosting ★ | ~0.11 | ~0.95 |
Gradient Boosting selected as best model. Random Forest retained for uncertainty quantification (variance across trees).
### Features
- Fermentation duration (d …