--- license: mit library_name: sklearn tags: - tabular-regression - agriculture - yield-prediction - coffee - vietnam - scikit-learn model_format: skops datasets: - synthetic --- # Coffee Yield Forecasting Model — Điện Biên, Vietnam Predicts **coffee yield (tons/hectare)** for districts in Điện Biên province, NW Vietnam, from growing-season weather features (rainfall timing by phenological stage, frost/cold days, growing degree days, elevation). Part of a broader [yield forecasting & harvest planning pipeline](https://github.com/) (weather ingestion → feature engineering → model → harvest-window + risk alerts). ## Model details - **Algorithm:** Random Forest - **Format:** [skops](https://skops.readthedocs.io/) (`model.skops`) — safe to load without pickle's arbitrary-code-execution risk - **Cross-validated MAE:** 0.115 t/ha (5-fold CV) - **Cross-validated R²:** 0.471 - **Training samples:** 80 (district-year observations) - **Trained:** 2026-07-18 ⚠️ **Important:** this model was trained on **synthetic, domain-informed weather+yield data**, not real measured yield records (see the parent repo's README for why, and how to retrain on real GSO/ICO data). Treat predictions as illustrative until retrained on real district-level yield history. ## Input features ``` dry_spell_rain_mm flowering_rain_mm fruitdev_rain_mm ripening_rain_mm fruitdev_rain_cv frost_days_sensitive mean_annual_temp_c growing_degree_days mean_sunshine_ripening elevation_m annual_rain_mm ``` All features are derived from daily weather (`tmax_c, tmin_c, tmean_c, precip_mm, et0_mm, sunshine_hours`) aggregated over crop-specific phenological windows — see `features.py` in the parent repo for exact definitions (e.g. `flowering_rain_mm` = total rainfall during the flowering month(s), `frost_days_sensitive` = count of nights below the frost threshold during frost-sensitive months). ## Usage ```python from huggingface_hub import hf_hub_download import skops.io as sio import pandas as pd model_path = hf_hub_download(repo_id="imaflower/dienbien-coffee-yield", filename="model.skops") model = sio.load(model_path, trusted=sio.get_untrusted_types(file=model_path)) X = pd.DataFrame([{ "dry_spell_rain_mm": 30, "flowering_rain_mm": 60, "fruitdev_rain_mm": 450, "ripening_rain_mm": 120, "fruitdev_rain_cv": 1.8, "frost_days_sensitive": 1, "mean_annual_temp_c": 21.5, "growing_degree_days": 4200, "mean_sunshine_ripening": 6.2, "elevation_m": 900, "annual_rain_mm": 1600 }]) predicted_yield_t_ha = model.predict(X)[0] ``` ## Intended use & limitations - Scoped to Điện Biên province district-level, seasonal (annual) yield forecasting — not validated for other provinces/climates without retraining. - Does not account for management practices (fertilization, pest control, variety-specific agronomy beyond the multiplier applied in the parent pipeline's `predict.py`). - Synthetic training data encodes plausible agronomic relationships but is not a substitute for real yield statistics.