DigiCow Farmer Training Adoption — Zindi Competition

Predict the **probability** that a farmer will adopt a DigiCow-supported

TL;DR: When input data contains free-text categories entered by humans in the field, NLP normalization (typo fixing + fuzzy deduplication) is the highest-leverage step in the entire pipeline. Clean categories enable meaningful aggregation features (per-category rates, quality scores) that wouldn't exist without normalization. Fix the data before fitting the model — it's worth more than any hyperparameter search.

The Problem

Agricultural training adoption prediction requires understanding that farmer behavior depends heavily on topic relevance, geographic context, and the timing of the training delivery. The task was to predict the probability that a farmer would adopt a DigiCow-supported practice within 7, 90, and 120 days of their first training session. Three time horizons, three separate predictions, all using only information available at the moment of training.

The hardest part wasn't the modeling — it was the data. Training topics were entered as free text by field trainers, riddled with typos, abbreviations, and inconsistent naming. "Artificial Insemination," "AI," "artficial insem," and "A.I. cattle" all referred to the same topic. Without normalizing these into canonical forms, the feature space would be impossibly fragmented — thousands of unique strings where fewer than 120 actual topics existed. Any model built on raw topic strings would learn noise.

The three time horizons added a structural constraint: adoption probability must be monotonically non-decreasing. The probability of adoption within 120 days must be at least as high as within 90 days, which must be at least as high as within 7 days. A model that violates this constraint produces logically impossible predictions — and gradient boosting models have no built-in mechanism to enforce monotonicity across multiple targets.

My Approach

The first battle was NLP topic normalization. I built a pipeline that fixed typos, expanded abbreviations, and then applied Levenshtein fuzzy matching to merge remaining variants into 117 canonical topics. This isn't a standard NLP problem — it's a specialized deduplication task where domain knowledge matters more than language models. Knowing that "AI" in agricultural context means "Artificial Insemination" rather than "Artificial Intelligence" requires domain-aware rules before fuzzy matching handles the residual cases.

From the normalized topics, I engineered features that capture topic-level adoption patterns: per-topic adoption rates (what fraction of farmers trained on this topic eventually adopt?), topic quality bins (Low/Medium/High/VeryHigh based on historical adoption rates), and topic category counts (how many dairy vs. poultry vs. livestock topics in this session). These features encode the fundamental insight that some topics are inherently more adoptable than others — a practical skill like "milking hygiene" has higher adoption rates than an abstract concept like "farm business planning."

Geographic context proved equally important. I computed adoption rates at county, subcounty, and ward levels — capturing the reality that farming communities influence each other. If your neighbors adopted a practice, you're more likely to adopt it too. Kenya's agro-ecological zones (High-potential, Medium, Semi-Arid) added another geographic layer, reflecting that practices viable in high-rainfall areas may be irrelevant in arid regions. Interaction terms between zone and training characteristics captured these geographic moderating effects.

The modeling used Bayesian optimization across six model families (LightGBM, XGBoost, Ranger, CatBoost, H2O AutoML, GLMNet), with six different sampling strategies to handle the 11% class imbalance in the 7-day target. A freeze set matched to the test distribution provided unbiased model comparison. The final step enforced monotonicity — if the 90-day prediction was lower than the 7-day prediction, it was corrected upward. This post-hoc fix ensured logical consistency without constraining the models during training.

Key Decisions

NLP Topic Normalization via Fuzzy Matching

Typo correction + abbreviation expansion + Levenshtein fuzzy merging reduced thousands of free-text topic strings to 117 canonical forms. Without this, every model would learn from a fragmented, noisy feature space where the same topic appears as dozens of unique strings. The normalization step is worth more than any hyperparameter tuning because it fixes the input data itself.

Topic Adoption Scores as Features

Computing per-topic historical adoption rates transforms a categorical variable (which topic?) into a numeric signal (how adoptable is this topic?). This captures the domain insight that topic relevance drives adoption more than farmer demographics. A farmer trained on a highly-adoptable topic is likely to adopt regardless of other characteristics.

Multi-Level Geographic Rates

County, subcounty, and ward-level adoption rates capture community influence at different spatial scales. Adoption is social — farmers learn from neighbors. Geographic rates encode this social diffusion as a feature, letting the model account for the reality that location predicts behavior through community effects, not just environmental suitability.

Post-Hoc Monotonicity Correction

Enforcing that prediction at 120 days ≥ 90 days ≥ 7 days after training ensures logical consistency without constraining model flexibility during training. Each model optimizes freely for its target horizon, and the correction step fixes the rare cases where independent predictions violate the necessary ordering. This preserves model expressiveness while guaranteeing coherent outputs.

Key Takeaway

This project demonstrated that data cleaning can be the highest-leverage modeling decision. The NLP topic normalization — reducing thousands of noisy strings to 117 canonical topics — created the foundation for every useful feature downstream. Without clean topic labels, per-topic adoption rates are meaningless, topic categories are fragmented, and the model learns from noise rather than signal. In messy real-world data, the preprocessing pipeline that fixes input quality is often worth more than the modeling pipeline that fits the patterns.

Design insight: When input data contains free-text categories entered by humans in the field, NLP normalization (typo fixing + fuzzy deduplication) is the highest-leverage step in the entire pipeline. Clean categories enable meaningful aggregation features (per-category rates, quality scores) that wouldn't exist without normalization. Fix the data before fitting the model — it's worth more than any hyperparameter search.

FAQ

What is the key takeaway from "DigiCow Farmer Training Adoption"?

When input data contains free-text categories entered by humans in the field, NLP normalization (typo fixing + fuzzy deduplication) is the highest-leverage step in the entire pipeline. Clean categories enable meaningful aggregation features (per-category rates, quality scores) that wouldn't exist without normalization. Fix the data before fitting the model — it's worth more than any hyperparameter search.

Who wrote this and what is it about?

This was written by Mahmoud Trigui, Senior Data Scientist. Predict the **probability** that a farmer will adopt a DigiCow-supported

Comments

Machine Learning Feature Engineering MLForecast Time Series Decomposition Forecasting LightGBM XGBoost Catboost Clustering Segmentation NLP LLMs Web App R Markdown SQL Oracle DB SAS-Guide SAS E-Miner Dataiku BigQuery GCP Python R CRISP-DM Hypothesis Testing ANOVA Data Analytics Dimensionality Reduction Recommendation System Network Analysis Geospace Analysis Spatial Data Embedding Sampling Techniques Decision Rules Data Storytelling CVM Churn Fraud Detection Sentiment Analysis Topic Modeling IBM Watson PowerBI Looker Studio VBA Statistical Learning Ensemble Modeling Stacking Cross-Validation Profiling ABT Construction Plumber Tidyverse Shiny Prophet Deep Learning Scikit-Learn JSON SAS Programming Git VS Code CSS Styling Automated Reporting Outlier Detection Temporal Clustering Startup Survival Pre-Valuation Modeling K-Means Decision Trees Data Science Predictive Modeling SVM LDA Text Classification Weight Prediction Pattern Recognition Real-Time Detection Community Detection Pipeline Automation Data Quality Checks Data Reliability Specification Mapping Business Strategy Marketing Campaigns Try & Buy Frameworks KPI Dashboards Network Quality Sales Analytics Mentoring Statistics Lecturer Remote Work Hybrid Work Consulting Contract Full-Time Freelance Sofrecom Orange Group Tunisia Telecom Kiota Intelligence VC Analytics Series A Prediction Production ML Applied AI Prompt Engineering Business Forecasting Decision Systems Graph Analytics Household Detection Multi-SIM Detection FTTH Forecasting Audit Extraction Infrastructure Classification Pydantic GPT-4 OpenAI API Base64 Classification Zindi Codementor LAAS-CNRS ESSAI MIT xPRO Tunisia ML Competition Cell Tower Analysis Uber Logistics Uber Cape Town Necessary Condition Analysis Behavioral Signals Spike Smoothing Observation Unit Design Dendrogram Ward Clustering VIF Target Encoding Machine Learning Feature Engineering MLForecast Time Series Decomposition Forecasting LightGBM XGBoost Catboost Clustering Segmentation NLP LLMs Web App R Markdown SQL Oracle DB SAS-Guide SAS E-Miner Dataiku BigQuery GCP Python R CRISP-DM Hypothesis Testing ANOVA Data Analytics Dimensionality Reduction Recommendation System Network Analysis Geospace Analysis Spatial Data Embedding Sampling Techniques Decision Rules Data Storytelling CVM Churn Fraud Detection Sentiment Analysis Topic Modeling IBM Watson PowerBI Looker Studio VBA Statistical Learning Ensemble Modeling Stacking Cross-Validation Profiling ABT Construction Plumber Tidyverse Shiny Prophet Deep Learning Scikit-Learn JSON SAS Programming Git VS Code CSS Styling Automated Reporting Outlier Detection Temporal Clustering Startup Survival Pre-Valuation Modeling K-Means Decision Trees Data Science Predictive Modeling SVM LDA Text Classification Weight Prediction Pattern Recognition Real-Time Detection Community Detection Pipeline Automation Data Quality Checks Data Reliability Specification Mapping Business Strategy Marketing Campaigns Try & Buy Frameworks KPI Dashboards Network Quality Sales Analytics Mentoring Statistics Lecturer Remote Work Hybrid Work Consulting Contract Full-Time Freelance Sofrecom Orange Group Tunisia Telecom Kiota Intelligence VC Analytics Series A Prediction Production ML Applied AI Prompt Engineering Business Forecasting Decision Systems Graph Analytics Household Detection Multi-SIM Detection FTTH Forecasting Audit Extraction Infrastructure Classification Pydantic GPT-4 OpenAI API Base64 Classification Zindi Codementor LAAS-CNRS ESSAI MIT xPRO Tunisia ML Competition Cell Tower Analysis Uber Logistics Uber Cape Town Necessary Condition Analysis Behavioral Signals Spike Smoothing Observation Unit Design Dendrogram Ward Clustering VIF Target Encoding