A Hybrid Model for Crop Yield Prediction Using Recurrent Neural Networks and Explainable Artificial Intelligence
Abstract
Accurate maize yield prediction is essential for ensuring food security and supporting agricultural planning in Kenya. However, the changes in climate and severe weather are posing more challenges to the stability of yield and food security. While advanced machine learning models, such as Long Short–Term Memory (LSTM) networks, offer strong predictive performance, their inherent "black–box" nature limits their practical adoption by farmers and policymakers who require interpretable and trustworthy insights. This study developed a transparent predictive model by integrating LSTM with Explainable Artificial Intelligence (XAI). Using county–level maize yield data (2012–2023), the hybrid model was compared against Random Forest and Gradient Boosting baselines. The LSTM model achieved superior performance (R² = 0.8551, RMSE = 0.3715, MAE = 0.2705), compared to Random Forest (R2 = 0.8441, RMSE= 0.3851 and MAE= 0.2856) and Gradient Boosting (R2 = 0.7925, RMSE = 0.4443 and MAE = 0.3234) baselines. XAI analysis, using SHapley Additive explanations (SHAP) and Local Interpretable Model–agnostic Explanations (LIME), identified longitude, latitude, and annual rainfall as key predictors. The model maintained high accuracy while improving interpretability, increasing transparency and trust. This provides actionable insights for farmers and policymakers, supporting evidence–based planning and enhancing resilience in smallholder systems. Keywords: Crop yield prediction, long short–term memory (LSTM), explainable artificial intelligence, precision agriculture, machine learning.