Research-oriented web application predicting maize yield and market prices at Kenya's county level. Combines machine learning models, real-time data analytics, and an intuitive dashboard for agricultural producers and researchers. Includes county intelligence reports, prediction history, and model explainability features.
# Kenya Maize Intelligence
Research-oriented web application for predicting **maize yield** and **maize prices** at the Kenya county level.
## Quick start
See **docs/LOCAL_DEVELOPMENT.md** for full instructions.
```powershell
# 1. ML pipeline (clean data + train models)
.\.venv\Scripts\python -m ml.run_pipeline
# 2. Initialize database
cd backend
$env:PYTHONPATH="."
..\.venv\Scripts\python scripts\init_db.py
# 3. Start API
..\.venv\Scripts\uvicorn app.main:app --reload --port 8000
# 4. Start React (new terminal)
cd frontend
npm run dev
```
Open
localhost — login with `producer@demo.ke` / `producer123`
## Stack
- **Frontend:** React + TypeScript + Tailwind + Recharts
- **Backend:** FastAPI REST + JWT + SQLAlchemy
- **Database:** SQLite (local dev) or PostgreSQL + pgAdmin 4 (Docker)
- **ML:** scikit-learn, XGBoost — yield & price models with feature explainability
## Project layout
```
kenya-maize-intelligence/
├── backend/ # FastAPI REST API
├── frontend/ # React dashboard
├── ml/ # Data cleaning & model training
├── data/
│ ├── raw/ # Your original datasets
│ └── processed/ # Cleaned merged outputs
└── docs/ # Documentation
```
## Model results (honest evaluation, test ≥ 2023)
| Task | Best model | R² | RMSE |
|------|------------|-----|------|
| Yield | Linear Regression | 0.28 | 0.86 t/ha |
| Price | Linear Regression | 0.31 | 7.49 KES/kg |
## Data
Raw data from your capstone folder. See docs/DATA_INVENTORY.md.
## Azure
Deployment guide coming in `docs/LOCAL_DEVELOPMENT.md` when you're ready — we'll use your Azure Student account with App Service + PostgreSQL.