Explainable machine learning for crop recommendation using statistical validation and SHAP interpretability in South Asian agricultural data
摘要
Agricultural decision-support systems powered by machine learning (ML) have emerged as critical tools for enhancing crop productivity and food security, particularly for smallholder farmers in developing regions. However, many existing models lack methodological rigor, statistical validation, and interpretability—key requirements for real-world deployment. This study presents a comprehensive, reproducible ML framework for crop recommendation that integrates comparative feature selection, multi-model benchmarking, statistical significance testing with Nadeau–Bengio correction, and SHAP-based explainability. Using a dataset of 10,000 agricultural records from South Asia comprising 36 original features reduced to 10 selected predictors, we evaluated seven base classifiers alongside two ensemble strategies. Random Forest achieved the highest fivefold cross-validated accuracy (79.8%, 95% CI [79.0–80.6%]) and Macro F1 (0.474, 95% CI [0.455–0.492]), with consistent performance under tenfold cross-validation (accuracy: 79.7%, 95% CI [79.1–80.4%]; Macro F1: 0.471, 95% CI [0.460–0.482]). The Friedman test confirmed significant differences among models (χ2 = 25.25, df = 7, p < 0.001). Nadeau–Bengio corrected post-hoc testing revealed that Random Forest significantly outperformed only SVM and Logistic Regression (p < 0.05), while differences with gradient-boosting models were statistically non-significant in fivefold CV, though tenfold analysis showed marginal significance against Gradient Boosting (p = 0.0243). SHAP analysis identified rainfall (mean |SHAP|= 0.0772), temperature (0.0613), soil pH (0.0300), and nitrogen content (0.0244) as the top predictive features. Regional analysis revealed crop-specific optimal conditions: Rice (pH 5.48–7.43, rainfall 2209 mm), Wheat (pH 6.39–7.79, rainfall 1470 mm), Maize (pH 5.13–6.89, rainfall 1048 mm), and Cotton (pH 5.07–6.63, rainfall 594 mm). All code, data, and artifacts are publicly available. While pronounced class imbalance inherently constrains minority-class prediction, this framework establishes methodological standards for reproducible, interpretable agricultural AI by prioritizing statistical validation with proper dependence correction, imbalance-aware evaluation, and agronomic explainability.