Journal DOI 10.68956/journal.human-performance-futures

Creative Commons source reading · Machine learning for performance

Controlled image-based prediction of soil nutrient concentrations (NPK) using machine and deep learning

Maqsood U; Karamat Ullah Khan T; Jhanjhi NZ; Sattar K; Iftikhar F; Imtiaz Ali N; Mehmood RM

Originally published in PLoS One · 2026-10-27

From the article

Selected source text. JournalOS removes markup and shortens excerpts where indicated. The full article provides the complete context.

Abstract

AbstractSoil nutrient analysis is essential for sustainable agriculture and precision farming. Traditional chemical tests for nitrogen, phosphorus, and potassium are reliable but costly, time-consuming, and often unavailable in remote areas. The objective of this study is to develop a novel approach that combines laboratory chemical extraction, controlled image acquisition, image processing, machine learning, and deep learning to classify soil nitrogen, phosphorus, and potassium levels. 50 independent soil samples were analyzed, chemically extracted, and classified as Low, Medium, or High for each nutrient. A specially designed black-box prototype was developed to capture high-quality images of soil extract samples under consistent lighting conditions. The images were used to extract color and texture information, which was evaluated…

Results

The final evaluation was performed on 50 independent physical soil samples. Derived image variants were included only in the training data and were not counted as additional independent observations, and no single 80:20 train-test split was used in the final evaluation for the classical machine-learning analysis. Rather, a leakage-controlled nested sample-level cross-validation, with five outer folds and three inner folds, was used, with a fixed random seed of 42. The inner folds were used to apply hyperparameter tuning, while the outer folds were used to produce out-of-fold predictions for the independent physical samples. The CNN was validated separately by leakage-controlled out-of-fold validation with augmentation restricted to the corresponding training data

Nested cross-validation results of the classical ML models

The final classical ML results were obtained from the inner-fold hyperparameter search and selected by pooled outer-fold macro-F1 score, as shown in Fig 13. By comparing the results of these models with each other, as presented in Table 9, KNN achieved an accuracy of 60% for nitrogen, Random Forest achieved 82% for phosphorus, and Logistic Regression achieved 48% for potassium. The KNN accuracy for nitrogen was slightly lower than the majority baseline of 62%. The macro-F1 score is 0.385, and its balanced accuracy is 38.5%, indicating that classification performance differed across classes. The model mainly classified the Medium and High classes; the single Low nitrogen sample was not classified correctly. In the case of phosphorus, Random Forest reached 82% accuracy, which was the same as the 82% majority-class baseline. A confusion…

Editorial reading guide

  • What data created and tested the model, and was evaluation independent?
  • What is the cost of a false positive, false negative or out-of-distribution decision?