An Explainable Transformer-Based Deep Learning Framework for Crop Sustainability Prediction in Sustainable Agriculture
Received: 21 March 2026 | Revised: 12 May 2026 | Accepted: 15 May 2026 | Online: 24 May 2026
Corresponding author: Salma Firdose
Abstract
Data-intensive decision support systems that recommend crops that are in accordance with local soil and climatic conditions are essential for sustainable agriculture. Crop sustainability prediction is difficult because seven agronomic variables, namely nitrogen, phosphorus, potassium, temperature, humidity, rainfall, and soil pH, interact in nonlinear ways that fixed-rule guidelines and shallow statistical models cannot capture. Current approaches also offer limited interpretability and little evaluation of prediction reliability, reducing their practical value for agricultural decision-making. This paper presents the Crop Sustainability Prediction Framework (CSPF), a transformer-based deep learning model designed for accurate and calibrated multi-class crop sustainability forecasting. CSPF includes a transformer classification network that models complex relationships among soil and climatic variables, an explainable feature attribution module using SHAP and Integrated Gradients to quantify how each environmental variable influences predictions, and a calibration-based reliability assessment using Expected Calibration Error (ECE) and Brier score. CSPF was evaluated on a crop recommendation dataset of 2,200 samples spanning 22 crop types, achieving a classification accuracy of 0.982, a Macro-F1 score of 0.980, and a One-vs-Rest ROC-AUC of 0.996. Calibration results show an ECE of 0.029 and a Brier score of 0.056, indicating close alignment between predicted confidence and actual outcomes. Feature attribution identifies rainfall, temperature, and soil pH as the three variables with the highest mean absolute contribution. CSPF provides an accurate, interpretable, and calibrated framework for predicting crop sustainability in sustainable agriculture.
Keywords:
crop sustainability prediction, deep neural networks, transformer learning, Explainable AI (XAI), calibration reliability, sustainable agricultureReferences
A. B. Møller, V. L. Mulder, G. B. M. Heuvelink, N. M. Jacobsen, and M. H. Greve, "Can We Use Machine Learning for Agricultural Land Suitability Assessment?," Agronomy, vol. 11, no. 4, Apr. 2021.
M. K. Senapaty, A. Ray, and N. Padhy, "A Decision Support System for Crop Recommendation Using Machine Learning Classification Algorithms," Agriculture, vol. 14, no. 8, July 2024.
M. K. Senapaty, A. Ray, and N. Padhy, "IoT-Enabled Soil Nutrient Analysis and Crop Recommendation Model for Precision Agriculture," Computers, vol. 12, no. 3, Mar. 2023.
B. Dey, J. Ferdous, and R. Ahmed, "Machine learning based recommendation of agricultural and horticultural crop farming in India under the regime of NPK, soil pH and three climatic variables," Heliyon, vol. 10, no. 3, Feb. 2024.
F. S. Prity et al., "Enhancing Agricultural Productivity: A Machine Learning Approach to Crop Recommendations," Human-Centric Intelligent Systems, vol. 4, no. 4, pp. 497–510, Dec. 2024.
Y. Mahale et al., "Crop recommendation and forecasting system for Maharashtra using machine learning with LSTM: a novel expectation-maximization technique," Discover Sustainability, vol. 5, no. 1, June 2024, Art. no. 134.
S. M. Cheema and I. M. Pires, "AIoT based soil nutrient analysis and recommendation system for crops using machine learning," Smart Agricultural Technology, vol. 11, Aug. 2025, Art. no. 100924.
S. R. Gopi and M. Karthikeyan, "Effectiveness of Crop Recommendation and Yield Prediction using Hybrid Moth Flame Optimization with Machine Learning," Engineering, Technology & Applied Science Research, vol. 13, no. 4, pp. 11360–11365, Aug. 2023.
N. M. Basavaraju, U. B. Mahadevaswamy, and M. Srikantaswamy, "Optimized Crop Yield Forecasting Using the Naive Bayes Regression Algorithm in Smart Agriculture," Engineering, Technology & Applied Science Research, vol. 15, no. 6, pp. 28995–29001, Dec. 2025.
J. Richetti, F. I. Diakogianis, A. Bender, A. F. Colaço, and R. A. Lawes, "A methods guideline for deep learning for tabular data in agriculture with a case study to forecast cereal yield," Computers and Electronics in Agriculture, vol. 205, Feb. 2023, Art. no. 107642.
Y. Zhu et al., "A deep learning crop model for adaptive yield estimation in large areas," International Journal of Applied Earth Observation and Geoinformation, vol. 110, June 2022, Art. no. 102828.
S. C. Ibañez and C. P. Monterola, "A Global Forecasting Approach to Large-Scale Crop Production Prediction with Time Series Transformers," Agriculture, vol. 13, no. 9, Sept. 2023.
Y. Liu et al., "Rice Yield Prediction and Model Interpretation Based on Satellite and Climatic Indicators Using a Transformer Method," Remote Sensing, vol. 14, no. 19, Oct. 2022.
L. J. Galarza, M. Realpe, M. S. Viñán-Ludeña, M. F. Calderón, and S. Jaramillo, "AgriTransformer: A Transformer-Based Model with Attention Mechanisms for Enhanced Multimodal Crop Yield Prediction," Electronics, vol. 14, no. 12, June 2025.
M. Bhagat, "Crop Recommendation Dataset." Kaggle.
Downloads
How to Cite
License
Copyright (c) 2026 C. V. Mahalakshmi, Salma Firdose

This work is licensed under a Creative Commons Attribution 4.0 International License.
Authors who publish with this journal agree to the following terms:
- Authors retain the copyright and grant the journal the right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) after its publication in ETASR with an acknowledgement of its initial publication in this journal.
