Image-Based Soil Nutrient Prediction Using Machine Learning and Deep Learning Models

  • Preity Mishra

    CSIR-Central Institute of Mining and Fuel Research, Barwa Road, Dhanbad - 826001, India

  • S.K. Chaulya

    CSIR-Central Institute of Mining and Fuel Research, Barwa Road, Dhanbad - 826001, India

  • Vikash Kumar
  • Naresh Kumar
  • Abhinek Agarwal
  • Anant Stephen Besra
Article ID: 4241
Keywords: machine learning; computer vision; image processing; soil nutrient prediction; random forest; gradient boosting machine

Abstract

Recent advances in precision agriculture have enabled the use of machine learning and image processing for rapid soil nutrient assessment. This study presents a non-destructive approach for estimating soil nutrient content from digital soil images captured using a camera and analyzed through specialized software. A dataset of 1,500 soil images was processed using color correction, noise reduction, and feature extraction techniques to improve data quality. Five machine learning models, Random Forest, Extreme Gradient Boosting (XGBoost), Light Gradient Boosting Machine (LightGBM), Gradient Boosting Machine (GBM), and a Stacking Regressor, were evaluated for predicting nitrogen, phosphorus, and potassium levels. A Convolutional Neural Network (CNN) based deep learning model was served as a benchmark. No single model was best for every nutrient and metric. For nitrogen, GBM achieved the lowest test MAE (0.1652), whereas the Stacking Regressor achieved the highest test R² (0.9886). For potassium, Random Forest achieved the lowest test MAE (0.0051), whereas XGBoost achieved the highest test R² (0.9999). For phosphorus, XGBoost achieved both the lowest test MAE (0.1558) and the highest test R² (0.9929). Thus, the best-performing model depends on the nutrient and evaluation metric. Further validation using independent field datasets is required to establish robustness under diverse environmental conditions.

Published
2026-10-28
How to Cite
Mishra, P., Chaulya, S., Kumar, V., Kumar, N., Agarwal, A., & Besra, A. S. (2026). Image-Based Soil Nutrient Prediction Using Machine Learning and Deep Learning Models. Computing and Artificial Intelligence, 4(3). https://doi.org/10.59400/cai4241
Section
Article

References

[1]Davenport, J.R.; Jabro, J.D. Assessment of hand-held ion selective electrode technology for direct measurement of soil chemical properties. Commun. Soil Sci. Plant Anal. 2001, 32, 3077–3085. DOI: https://doi.org/10.1081/CSS-120001108

[2]Meenakshi, M.; Naresh, R. Soil health analysis and fertilizer prediction for crop image identification by Inception-V3 and Random Forest. Remote Sens. Appl.: Soc. Environ. 2022, 28, 100846. DOI: https://doi.org/10.1016/j.rsase.2022.100846

[3]Kanade, P. Soil Analysis using machine learning. Br. J. Multidiscip. Adv. Stud. 2023. 4, 1–11. DOI: https://doi.org/10.37745/bjmas.2022.0350

[4]Sheeba, T.B.; Vijay, A.L.D.; Manohar, G.; Saravana, S.C.; Bazil, W.C.; Muthukumar, K. Machine learning algorithm for soil analysis and classification of micronutrients in IoT-enabled automated farms. J. Nanomater. 2022. DOI: https://doi.org/10.1155/2022/5343965

[5]Li, D.; Li, C.; Yao, Y.; Li, M.; Liu, L. Modern imaging techniques in plant nutrition analysis: a review. Comput. Electron. Agric. 2020. 174, 105459. DOI: https://doi.org/10.1016/j.compag.2020.105459

[6]Puno, J.C.; Sybingco, E.; Dadios, E.; Valenzuela, I.; Cuello, J. Determination of soil nutrients and pH level using image processing and artificial neural network. In 9th International Conference on Humanoid, Nanotechnology, Information Technology, Communication and Control, Environment and Management, HNICEM 2017, 2017, pp. 1–6, IEEE. DOI: https://doi.org/10.1109/HNICEM.2017.8269472

[7]Padarian, J.; Minasny, B.; McBratney, A.B. Using deep learning to predict soil properties from regional spectral data. Geoderma Reg. 2019. 16, e00198. DOI: https://doi.org/10.1016/j.geodrs.2018.e00198

[8]Petersen, C.T.; Abrahamsen, P. Predicting effects of soil compaction on crop yield and nitrogen dynamics. Department of Plant and Environmental Sciences, University of Copenhagen. 2021. Retrieved from https://daisy.ku.dk/projects-and-collaboration/projects/commit/Simulating_compaction_effects_gudp.pdf

[9]Gomes, W.P.C.; Gonçalves, L.; da Silva, C.B.; Melchert, W.R. Application of multispectral imaging combined with machine learning models to discriminate special and traditional green coffee. Comput. Electron. Agric. 2022, 198, 107097. DOI: https://doi.org/10.1016/j.compag.2022.107097

[10]Attri, I.; Awasthi, L.K.; Sharma, T.P.; Rathee, P. A review of deep learning techniques used in agriculture. Ecol. Inform. 2023, 77, 102217. DOI: https://doi.org/10.1016/j.ecoinf.2023.102217

[11]Padarian, J.; Minasny, B.; McBratney, A.B. Machine learning and soil sciences: a review aided by machine learning tools. Soil. 2020, 6, 35–52, https://doi.org/10.5194/soil-6-35-2020

[12]Benos, L.; Tagarakis, A.C.; Dolias, G.; Berruto, R.; Kateris, D.; Bochtis, D. Machine learning in agriculture: a comprehensive updated review. Sensors, 2021, 21(11), 3758. DOI: https://doi.org/10.3390/s21113758

[13]Aggarwal, L.; Sachdeva, S.; Goswami, P. Quantum healthcare computing using precision based granular approach. Appl. Soft Comput. 2023, 144, 110458. DOI: https://doi.org/10.1016/j.asoc.2023.110458

[14]Meng, T.; Jing, X.; Yan, Z.; Pedrycz, W. A survey on machine learning for data fusion. Inf. Fusion. 2020, 57, 115–129. DOI: https://doi.org/10.1016/j.inffus.2019.12.001

[15]Kashyap, B.; Kumar, R. Sensing methodologies in agriculture for soil moisture and nutrient monitoring. IEEE Access. 2021, 9, pp. 14095–14121. DOI: https://doi.org/10.1109/ACCESS.2021.3052478

[16]Buthelezi, K.; Kibirige, D.M.K.; Buthelezi-Dube, N.N. The evolution of methods and tools used to assess soil health indicators − a scoping review. Geoderma, 2026, 468, 117765. DOI: https://doi.org/10.1016/j.geoderma.2026.117765

[17]Lin, J.; Wang, M.; Zhang, M.; Zhang, Y.; Chen, L. Electrochemical Sensors for Soil Nutrient Detection: Opportunity and Challenge. In: Li, D. (eds) Computer and Computing Technologies in Agriculture, Volume II. The International Federation for Information Processing, 2008, vol. 259. Springer, Boston, MA. DOI: https://doi.org/10.1007/978-0-387-77253-0_77

[18]Najdenko, E.; Lorenz, F.; Dittert, K.; Olfs, H.W. Rapid in-field soil analysis of plant-available nutrients and pH for precision agriculture - a review. Precision Agric. 2024, 25, 3189–3218. DOI: https://doi.org/10.1007/s11119-024-10181-6

[19]Wolpert, D.H. Stacked generalization. Neural Netw. 1992, 5(2), 241–259. DOI: https://doi.org/10.1016/S0893-6080(05)80023-1

[20]Breiman, L. Random forests. Mach. Learn. 2001. 45(1), 5–32. DOI: https://doi.org/10.1023/A:1010933404324

[21]Friedman, J.H. Greedy function approximation: a gradient boosting machine. Ann. Stat. 2001, 29(5), 1189–1232. DOI: https://doi.org/10.1214/aos/1013203451

[22]Chen, T.; Guestrin, C. XGBoost: A scalable tree boosting system. In Proceedings of the 22nd International Conference on Knowledge Discovery and Data Mining. 2016. pp. 785–794, ACM. DOI: https://doi.org/10.1145/2939672.2939785

[23]Ke, G.; Meng, Q.; Finley, T.; Wang, T.; Chen, W.; Ma, W.; Liu, T.Y. LightGBM: A highly efficient gradient boosting decision tree. In 31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA. https://proceedings.neurips.cc/paper_files/paper/2017/file/6449f44a102fde848669bdd9eb6b76fa-Paper.pdf

[24]Liakos, G.K.; Busato, P.; Moshou, D.; Pearson, S.; Bochtis, D. Machine learning in agriculture: a review. Sensors. 2018, 18, 2674. DOI: https://doi.org/10.3390/s18082674

[25]Wu, C.; Chen, Y.; Hong, X.; Liu, Z.; Peng, C. Evaluating soil nutrients of Dacrydium pectinatum in China using machine learning techniques. For. Ecosyst. 2020, 7, 30. DOI: https://doi.org/10.1186/s40663-020-00232-5

[26]Xu, Z.; Guo, X.; Zhu, A.; He, X.; Zhao, X.; Han, Y.; Subedi, R. Using deep convolutional neural networks for image-based diagnosis of nutrient deficiencies in rice. Comput. Intell. Neurosci. 2020, 7307252. DOI: https://doi.org/10.1155/2020/7307252

[27]Srivastava, P; Shukla, A.; Bansal, A. A comprehensive review on soil classification using deep learning and computer vision techniques. Multimed. Tools Appl. 2021, 80(10), 14887–14914. DOI: https://doi.org/10.1007/s11042-021-10544-5

[28]Folorunso, O.; Ojo, O.; Busari, M.; Adebayo, M.; Joshua, A.; Folorunso, D.; Ugwunna, C.O.; Olabanjo, O.; Olabanjo, O. Exploring machine learning models for soil nutrient properties prediction: a systematic review. Big Data Cogn. Comput. 2023, 7, 113. DOI: https://doi.org/10.3390/bdcc7020113

[29]Sumathi, P.; Karthikeyan, V.V.; Kavitha, M.S.; Karthik, S. Improved soil quality prediction model using deep learning for smart agriculture systems. Comput. Syst. Sci. Eng. 2023, 45(2), 1545–1559. DOI: https://doi.org/10.32604/csse.2023.027580

[30]Sajindra, H.; Abekoon, T.; Jayakody, J.A.D.C.A.; Rathnayake, U. A novel deep learning model to predict the soil nutrient levels (N, P, and K) in cabbage cultivation. Smart Agr. Technol. 2024, 7. DOI: https://doi.org/10.1016/j.atech.2023.100395

[31]Chaudhary, A.; Singh, P.D.; Verma, R.; Sharma. M. Monitoring soil health using machine learning techniques for improved crop yield prediction. Cureus J. Comput. Sci. 2025, 2. DOI: https://doi.org/10.7759/s44389-025-04577-2

[32]Kumar, A.; Moharana, P.C; Jena, R.K.; Malyan, S.K.; Fagodiya, R.K.; Shabnam, A.A.; Vinodakumar, S.N.; Jigyasu, D.K.; Gull, A.; Kumari, K.M.V.; Subramaniam, G.D. Prediction of soil available nitrogen using machine learning and digital mapping techniques in Northeast India. Environ. Chall. 2026, 22, 101375. DOI: https://doi.org/10.1016/j.envc.2025.101375

[33]Rao, R.R.; Reddy, U.S. Agrimind intelligent deep learning framework for accurate soil fertility prediction. Sci. Rep. 2026, 16, 19657. DOI: https://doi.org/10.1038/s41598-026-50366-9