What Drives Smallholder Yields in Tanzania? An Interpretable Machine Learning Analysis of Inputs, Climate Shocks, and the Gender Yield Gap
Abstract
Machine learning has seen wide use in agricultural yield prediction globally, yet Tanzania remains almost entirely overlooked in this body of work despite agriculture employing the bulk of its workforce. Drawing on five waves (2008–2021) of Tanzania's National Panel Survey, part of the World Bank's Living Standards Measurement Study: Integrated Surveys on Agriculture (LSMS-ISA), we build an interpretable machine learning pipeline that sorts smallholder plots into low, medium, and high yield terciles using 33 plot-, household-, and manager-level features. An XGBoost classifier reaches 61.4\% accuracy and a macro F1 of 0.61 on a balanced three-class task (chance level: 33\%), outperforming both a random forest and a logistic regression baseline. Applying SHAP (SHapley Additive exPlanations), we identify plot area, crop choice, drought shock, and input use (seed and nitrogen fertilizer) as the strongest predictors, and show that the model recovers two patterns already well established in the agricultural economics literature but seldom surfaced through machine learning on Tanzania-specific data: an inverse relationship between plot size and yield, and a gender yield gap that disadvantages female-managed plots. We argue that pairing predictive modeling with interpretability yields a low-cost, low-resource-appropriate tool for separating actionable drivers of yield (inputs, irrigation) from structural constraints (gender, wealth, geography) that call for policy rather than technical intervention.