Logo Lanfrica

WilsonNedanhe/agri-ai

Domain:

agriculture

Record type:

softwaremodel
Creator:
Wil
Host:
AI-powered crop risk classification API for Zimbabwe smallholder farmers binary risk (Low/Elevated) from climate and market signals, built for POTRAZ AI4I Track 3 # AgriRisk — Crop Risk Advisory API AI-powered crop risk classification for Zimbabwe smallholder farmers, built for the POTRAZ AI4I Challenge, Track 3 — Development. ## About Smallholder farmers in Zimbabwe make critical seasonal decisions — input purchase timing, irrigation prioritization, pest response — with limited access to consolidated climate and market signal data. AgriRisk is a lightweight FastAPI service that classifies crop risk (Low vs Elevated) from nine raw, farmer-answerable inputs, and returns a one-line actionable recommendation alongside the prediction. The project deliberately scopes itself to what the data can actually support. A yield-prediction module was built, tested, and **dropped**: a feature-importance audit showed 92% of its apparent accuracy came from a single crop-identity flag rather than any real climate signal — a crop lookup table, not a climate-risk model. That decision, and the reasoning behind it, is disclosed in the `/health` endpoint and in the full technical proposal. ## Endpoints | Method | Path | Description | |---|---|---| | `POST` | `/predict` | Binary risk classification (Low/Elevated) + probabilities + action recommendation, from raw inputs | | `GET` | `/districts` | District-level descriptive statistics (% elevated risk, dominant risk level, high-risk crops, historical average yield) — computed directly from recorded data, no model call | | `GET` | `/health` | Model metrics and mandatory dataset provenance / limitation disclosure | ## Model - **Algorithm:** Gradient Boosted Tree (scikit-learn `GradientBoostingClassifier`, 200 estimators, max depth 4) - **Target:** Binary — Low / Elevated risk (collapsed from an original 3-class target; the High-risk class had only 15/360 rows and scored 0.00 precision/recall/F1 under cross-validation, so a 3-class model would have been indefensible) - **Validation:** 5-fold cross-validated balanced accuracy of 0.804 ± 0.040 - **Why ML at all:** a single-variable rainfall thresho …