Interactive dashboard for the Kenya coffee sector (2018–2020) using 2,784 growers and 157 dealers. Includes ML models (Random Forest, KMeans, anomaly detection), cluster profiles, geo-visualisation, 12-month and 20 year-registration projections. Built with vanilla HTML/CSS + Chart.js.
# Kenya Coffee Sector — Advanced ML Analysis Project
**Author:** Chege-N |
**Dataset:** Kenya Coffee Growers (2,784) + Dealers (157) | **Period:** 2018–2020
---
## Project Structure
```
kenya_coffee_project/
├── data/
│ ├── coffeedealers_raw.csv # Original dealer data (157 records)
│ ├── coffeegrowers_raw.csv # Original grower data (2,784 records)
│ ├── growers_processed.csv # Feature-engineered growers
│ ├── dealers_processed.csv # Feature-engineered dealers
│ └── geo_data.json # 897 georeferenced growers (JSON)
├── analysis/
│ └── kenya_coffee_analysis.py # Full ML pipeline script
├── models/
│ └── (model artifacts if saved)
└── outputs/
├── kenya_coffee_dashboard.html # Interactive dashboard (open in browser)
└── analysis_summary.json # Machine-readable results summary
```
---
## Datasets
### Coffee Growers (`coffeegrowers.csv`)
- **2,784 records**, 25 columns
- Date range: 2018-04-28 → 2020-09-18
- Key fields: `id`, `title`, `actor`, `lat`, `lon`, `county_name_id`, `active`, `created`, `updated`
- Actor types: Factory (983), Small Estates (984), Cooperative Society (494), Estate Producers (320)
### Coffee Dealers (`coffeedealers.csv`)
- **157 records**, 7 columns
- Key fields: `id`, `title`, `license_number`, `nce_ref`, `notes`, `website`
---
## ML Models Applied
| Model | Purpose | Key Metric |
|-------|---------|-----------|
| **Random Forest** (n=200) | Predict grower active status | F1=0.630 (5-fold CV) |
| **Gradient Boosting** | Compare classifier | F1=0.580 |
| **Logistic Regression** | Baseline classifier | F1=0.410 |
| **KMeans** (k=4) | Grower segmentation | 4 distinct clusters |
| **Isolation Forest** | Anomaly detection | 136 anomalies (4.9%) |
| **PCA** (2D) | Dimensionality reduction | 68.2% variance explained |
| **Linear Regression** | Registration trend + projection | R²=0.21 |
---
## Key Findings
### Growers
1. **Only 10.8% of growers are active** (301/2,784). Sm …