Ensuring Robustness in IoT-Based Precision Agriculture: A Stacked Ensemble Model Resilient to Sensor Noise and Data Failures

Authors

  • Iftikhar Hussain Department of Computer Science & Information Technology, Ghazi University, Dera Ghazi Khan
  • Muhammad Afzal Department of Computer Science & Information Technology, Ghazi University, Dera Ghazi Khan
  • Saddam Hussain Department of Computer Science & Information Technology, Ghazi University, Dera Ghazi Khan
  • Benish Department of Computer Science & Information Technology, Ghazi University, Dera Ghazi Khan
  • Ali Raza Sheikh Department of Computer Science & Information Technology, Ghazi University, Dera Ghazi Khan

Keywords:

Precision Agriculture, Stacked Ensemble Learning, Genetic Algorithm, SHAP, Explainable AI, Fertilizer Recommendation, Bayesian Optimization

Abstract

The increasing need for sustainability in agriculture has driven the use of data-based techniques in crop management and fertilizer recommendations. Conventional methods, which depend on either static set of rules or basic machine learning classification algorithms, are sometimes inadequate in addressing the issues presented by a dynamic agricultural environment. In this paper, a resilient and hierarchical stacked ensemble method that can provide precise, reliable, and uncertainty-aware fertilizer recommendations for precision agriculture is discussed. The methodology involves combining three gradient boosting learners: XGBoost; LightGBM; and CatBoost under a Ridge Regression model, using stratified five-fold cross-validation. Hyperparameters are optimized through Bayesian optimization with the Optuna library, and the Genetic Algorithm is employed as an optimization algorithm after prediction to reduce the fertilizer amount used while maintaining the nutrient content of the soil. Newly engineered features include environment-based indices such as Heat Index, Climate Stress Index, Soil Fertility Index, and different ratios of nutrients to enrich the existing feature set. Dimensionality reduction in terms of IoT deployment feasibility is ensured by Recursive Feature Elimination. The explainability is done by interpreting the SHAP values while the measurement of uncertainty is based on the confidence intervals. Using the public Crop Recommendation dataset consisting of 2,200 samples in 22 crop classes, the classification results for the proposed framework show an accuracy of 93.44%, F1 score of 93.47%, Cohen's Kappa of 0.9313, and Matthews Correlation Coefficient of 0.9315. The confidence of this model stands at 92.02%, whereas its accuracy against 5% Gaussian noise is 91.57%.

References

“The future of food and agriculture – Drivers and triggers for transformation,” Futur. food Agric. – Drivers triggers Transform., Dec. 2022, doi: 10.4060/CC0959EN.

J. A. Foley et al., “Solutions for a cultivated planet,” Nat. 2011 4787369, vol. 478, no. 7369, pp. 337–342, Oct. 2011, doi: 10.1038/nature10452.

S. Hernandez, P., & Taylor, “Machine learning applications for precision agriculture: A comprehensive review.,” IEEE Trans. Precis. Farming, vol. 18, no. 1, pp. 80–95, 2024.

T. Ahmad et al., “Role of Smart Agriculture Techniques in Food Security: A Systematic Review,” J. Agron. Crop Sci., vol. 210, no. 5, p. e12758, Oct. 2024, doi: 10.1111/JAC.12758.

Lefteris Benos, Aristotelis C. Tagarakis, “Machine Learning in Agriculture: A Comprehensive Updated Review,” Sensors, vol. 21, no. 11, p. 3758, 2021, doi: https://doi.org/10.3390/s21113758.

Mahmudul Hasan, Md Abu Marjan, “Ensemble machine learning-based recommendation system for effective prediction of suitable agricultural crop cultivation,” Front. Plant Sci., vol. 14, 2023, doi: https://doi.org/10.3389/fpls.2023.1234555.

K. Rastogi, N. Pritmani, V. Fichadia, and S. Patel, “Predicting Agricultural Crop Yield in Indian States Using Machine Learning Models,” Commun. Comput. Inf. Sci., vol. 2619 CCIS, pp. 49–66, 2026, doi: 10.1007/978-3-032-00350-8_5/SAVE-RESEARCH.

Yaqoob Majeed, Longsheng Fu, “Editorial: Artificial intelligence-of-things (AIoT) in precision agriculture,” Front. Plant Sci., vol. 15, 2024, doi: https://doi.org/10.3389/fpls.2024.1369791.

Rania A. Ahmed, Walid El-Shafai, Zeinab A. Ahmed, El-Sayed M. El-Rabaie & Fathi E. Abd El-Samie, “High-precision crop recommendation system with stacking ensemble classifiers for optimizing agricultural productivity,” Sci. Rep., 2025, doi: https://www.nature.com/articles/s41598-025-09640-5.

T. G. Dietterich, “Ensemble methods in machine learning,” Lect. Notes Comput. Sci. (including Subser. Lect. Notes Artif. Intell. Lect. Notes Bioinformatics), vol. 1857 LNCS, pp. 1–15, 2000, doi: 10.1007/3-540-45014-9_1/SAVE-RESEARCH.

David H. Wolpert, “Stacked generalization,” Neural Networks, vol. 5, no. 2, 1992, [Online]. Available: https://www.sciencedirect.com/science/article/pii/

S0893608005800231

Tianqi Chen, Carlos Guestrin, “XGBoost: A Scalable Tree Boosting System,” arXiv:1603.02754, 2016, [Online]. Available: https://arxiv.org/abs/1603.02754

G. Ke et al., “LightGBM: A Highly Efficient Gradient Boosting Decision Tree”, Accessed: Oct. 10, 2025. [Online]. Available: https://github.com/Microsoft/LightGBM.

Saddam Hussain, Muhammad Jehanzeb Masud Cheema, “Implementation of Artificial Intelligence in Agriculture: An Editorial Note,” AgriEngineering, vol. 7, no. 12, p. 401, 2025, doi: https://doi.org/10.3390/agriengineering7120401.

M. Shahhosseini, G. Hu, and S. V. Archontoulis, “Forecasting Corn Yield With Machine Learning Ensembles,” Front. Plant Sci., vol. 11, Jul. 2020, doi: 10.3389/FPLS.2020.01120.

A. Adadi and M. Berrada, “Peeking Inside the Black-Box: A Survey on Explainable Artificial Intelligence (XAI),” IEEE Access, vol. 6, pp. 52138–52160, 2018, doi: 10.1109/ACCESS.2018.2870052.

S. M. Lundberg and S. I. Lee, “A Unified Approach to Interpreting Model Predictions,” Adv. Neural Inf. Process. Syst., vol. 2017-December, pp. 4766–4775, May 2017, Accessed: Aug. 14, 2024. [Online]. Available: https://arxiv.org/abs/1705.07874v2

A. A. Khan, M. Faheem, R. N. Bashir, C, “Internet of Things (IoT) Assisted Context Aware Fertilizer Recommendation,” IEEE Access, vol. 10, pp. 129505–129519, 2022, doi: 10.1109/ACCESS.2022.3228160.

D. E. Goldberg, “Genetic Algorithms in Search, Optimization and Machine Learning: Guide books | ACM Digital Library,” 1989, Accessed: Jun. 10, 2026. [Online]. Available: https://dl.acm.org/doi/10.5555/534133

“(PDF) Integrating Feature Selection and Deep Learning: A Hybrid Approach for Smart Agriculture Applications.” Accessed: Jun. 10, 2026. [Online]. Available: https://www.researchgate.net/publication/390759346_Integrating_Feature_Selection_and_Deep_Learning_A_Hybrid_Approach_for_Smart_Agriculture_Applications

“[PDF] A Deep Learning Enabled Multi-Class Plant Disease Detection Model Based on Computer Vision | Semantic Scholar.” Accessed: Jun. 10, 2026. [Online]. Available: https://www.semanticscholar.org/paper/A-Deep-Learning-Enabled-Multi-Class-Plant-Disease-Roy-Bhaduri/28d6a88de75d1228bb4412367267ff8a4fcb2bec

V. Kale and B. N. Mohapatra, “Crop Recommendation System Using Machine Learning,” J. Eng. Technol. Ind. Appl., vol. 10, no. 48, pp. 63–68, Jul. 2024, doi: 10.5935/jetia.v10i48.1186.

“(PDF) Green Growth: AI-Driven Intelligent Farming for Effective Resource Management.” Accessed: Jun. 10, 2026. [Online]. Available: https://www.researchgate.net/publication/395861087_Green_Growth_AI-Driven_Intelligent_Farming_for_Effective_Resource_Management

“Design of an integrated climatic assessment indicator (ICAI) for wheat production: A case study in Jiangsu Province, China.” Accessed: Jun. 10, 2026. [Online]. Available: https://www.researchgate.net/publication/333535531_Design_of_an_integrated_climatic_assessment_indicator_ICAI_for_wheat_production_A_case_study_in_Jiangsu_Province_China

P. Alaboz, M. S. Odabas, and O. Dengiz, “Soil quality assessment based on machine learning approach for cultivated lands in semi-humid environmental condition part of Black Sea region,” Arch. Agron. Soil Sci., vol. 69, no. 15, pp. 3514–3532, Sep. 2023, doi: 10.1080/03650340.2023.2248002.

Yang Cao, Haolong Xiang, Hang Zhang, Ye Zhu, Kai Ming Ting, “Anomaly Detection Based on Isolation Mechanisms: A Survey,” arXiv:2403.10802, 2024, [Online]. Available: https://arxiv.org/abs/2403.10802

Shichao Zhang, “Nearest neighbor selection for iteratively kNN imputation,” J. Syst. Softw., vol. 85, no. 11, pp. 2541–2552, 2012, doi: https://doi.org/10.1016/j.jss.2012.05.073.

BergstraJames and BengioYoshua, “Random search for hyper-parameter optimization,” J. Mach. Learn. Res., Feb. 2012, doi: 10.5555/2188385.2188395.

Bobak Shahriari, Kevin Swersky, “Taking the Human Out of the Loop: A Review of Bayesian Optimization,” Proceddings IEEE, vol. 104, no. 1, 2016, doi: 10.1109/JPROC.2015.2494218.

Takuya Akiba, Shotaro Sano, Toshihiko Yanase, Takeru Ohta, Masanori Koyama, “Optuna: A Next-generation Hyperparameter Optimization Framework,” arXiv:1907.10902, 2019, [Online]. Available: https://arxiv.org/abs/1907.10902

Yasunobu Nohara, Koutarou Matsumoto, “Explanation of machine learning models using shapley additive explanation and application for real data in hospital,” Comput. Methods Programs Biomed., vol. 214, p. 106584, 2022, doi: https://doi.org/10.1016/j.cmpb.2021.106584.

M. S. Tanha Talaviya, Dhara Shah, Nivedita Patel, Hiteshri Yagnik, “Implementation of artificial intelligence in agriculture for optimisation of irrigation and application of pesticides and herbicides,” Artif. Intell. Agric., vol. 4, pp. 58–73, 2020, doi: https://doi.org/10.1016/j.aiia.2020.04.002.

Alexandre Barbosa, Rodrigo Trevisan, “Modeling yield response to crop management using convolutional neural networks,” Comput. Electron. Agric., vol. 170, 2020, [Online]. Available: https://www.sciencedirect.com/science/article/pii/S0168169919308543

R. Akhter and S. A. Sofi, “Precision agriculture using IoT data analytics and machine learning,” J. King Saud Univ. - Comput. Inf. Sci., vol. 34, no. 8, pp. 5602–5618, 2022, doi: https://doi.org/10.1016/j.jksuci.2021.05.013.

Anastasios N. Angelopoulos, Stephen Bates, “A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification,” arXiv:2107.07511, 2022, [Online]. Available: https://arxiv.org/abs/2107.07511

Ö. Turgut, I. Kök, and S. Özdemir, “AgroXAI: Explainable AI-Driven Crop Recommendation System for Agriculture 4.0,” Proc. - 2024 IEEE Int. Conf. Big Data, BigData 2024, pp. 7208–7217, 2024, doi: 10.1109/BIGDATA62323.2024.10825771.

Downloads

Published

2026-06-09

How to Cite

Hussain, I., Afzal, M., Hussain, S., Benish, & Sheikh, A. R. (2026). Ensuring Robustness in IoT-Based Precision Agriculture: A Stacked Ensemble Model Resilient to Sensor Noise and Data Failures. International Journal of Innovations in Science & Technology, 8(3), 1139–1165. Retrieved from https://journal.50sea.com/index.php/IJIST/article/view/1923