Skip to Content
  • Proceeding Paper
  • Open Access

13 November 2026

10 Pages

Adaptive Sampling and Machine Learning-Based Soil Fertility Prediction Framework for Smart Agriculture Sensors †

and
1
Department of Computer Science and Engineering (CSE), Gandhi Institute of Engineering and Technology University, Gunupur 765022, Odisha, India
2
Department of Computer Science and Engineering (CSE (Allied)), Gandhi Institute of Engineering and Technology University, Gunupur 765022, Odisha, India
*
Author to whom correspondence should be addressed.
†
Presented at the 13th International Electronic Conference on Sensors and Applications, 18–20 November 2026; Available online: https://sciforum.net/event/ECSA-13.

Abstract

Soil fertility assessment is an important factor in precision agriculture. However, imbalanced soil datasets can reduce the reliability of machine learning predictions. This study proposes a ML soil fertility prediction framework including a data-balancing technique with multiple classifiers. A dataset comprising 880 soil samples and 12 physicochemical parameters was evaluated using various ML classifiers such as SVM (RBF), Gradient Boosting, LightGBM, Decision Tree, XGBoost, Extra Trees, Random Forest, LogR, MLP (sklearn), AdaBoost, Naive Bayes, and KNN combined with class-imbalance handling techniques such as SMOTE, BL-SMOTE Models evaluated with performance metrics, and cross-validation metrics. From our experimental results, it has been observed that among the twelve ML classifiers evaluated, the model SVM and RBF kernel obtained the highest accuracy of 94.26%, with an F-score of 0.9392. Apart from this, the study also used sampling strategies. This paper demonstrates that SMOTE achieved a 91.80% accuracy, outperforming BL-SMOTE with its 90.98% accuracy among the two reported resampling methods. These findings emphasize the need for assessing classifier performance and sampling procedures independently for soil fertility prediction. Apart from this, we conducted statistical significance analyses such as McNemar Test, ANOVA test. From statistical analysis results, ANOVA indicated no statistically significant difference among the top three performing models. Its p-value was obtained as 0.2232. Again, the Friedman test exhibited the most statistically significant overall difference of the 12 machine learning classifiers (p < 0.001).

1. Introduction

Soil is not just useful for holding the crop root but it is also an important natural resource that supports agricultural productivity, ecosystem stability, and food security. The physical, chemical, and biological characteristics of soil define soil fertility and directly influence crop growth, nutrient availability, water retention, and fertilizer efficiency. Conventional soil fertility assessment is generally done by physically collecting soil samples to be analyzed in laboratory chemical tests. A laboratory analysis might give reliable results, but the process can be expensive, time-consuming, and difficult to scale for frequent monitoring. These are the main reasons behind the increasing demand for rapid, data-driven and sensor-enabled soil assessment, monitoring and agricultural decision-making.
IoT, smart sensors, and ML enable continuous soil monitoring using parameters such as pH, EC, moisture, temperature, and nutrients. However, imbalanced datasets can bias ML models toward the majority of fertility classes, reducing minority-class recognition. Therefore, this study evaluates multiple sampling techniques with diverse ML models to improve the soil fertility classification.

3. Materials and Methods

This study proposes a framework which is called “Adaptive Sampling and Machine Learning-Based Soil Fertility Prediction Framework” for Smart Agriculture Sensors. In this study, ML classifiers such as DL models and sampling techniques are utilized for soil fertility prediction. This framework consists of seven sequential phases. In this paper we have implemented the ML and DL algorithm using Python (v3.x) and Google Colab Environment (Google LLC, available online: https://colab.research.google.com/, accessed on 11 July 2026), scikit-learn: 1.6.1, XGBoost: 3.4.1, LightGBM: 4.6.0.
Figure 1 represents the visual representation of the architecture and steps. The proposed framework comprises six phases: soil data acquisition, preprocessing, adaptive sampling using SMOTE and Borderline-SMOTE, ML model development using 11 classifiers, performance evaluation using accuracy, precision, recall, F1-score, Cohen’s Kappa, and MCC. The final step is the selection of the best model. Using 880 soil samples with 12 physicochemical attributes, the best-performing model is ultimately selected to classify soil fertility into Low, Medium, and High categories, providing a data-driven foundation for smart agriculture applications.
Figure 1. Proposed adaptive sampling and machine learning-based framework for soil fertility prediction using smart agriculture sensor data.

4. Setup, Results and Discussion

4.1. Experimental Setup

Table 1 presents the dataset characteristics for soil fertility prediction. The dataset is taken from the Kaggale repository [Source: https://www.kaggle.com/datasets/rahuljaiswalonkaggle/soil-fertility-dataset] accessed on 25 January 2026. Prior to being partitioned into training and testing subsets, the dataset underwent data quality assessment, target label encoding, and feature standardization. The twelve ML model were utilized and compared under the same experimental setting.
Table 1. Dataset characteristics for soil fertility prediction.
Table 2 presents the Experimental protocol for soil fertility prediction. In this article, we divided our dataset into two parts for training and testing set. A total of 80% of data goes into the training set and 20% data goes into the testing set with five-fold cross-validation. The role of the held-out test set is explained to differentiate the final model evaluation from model training and resampling, and the hyperparameter values are explained in accordance with the experimental implementation.
Table 2. Experimental protocol for soil fertility prediction.
In our dataset, the target feature contains three class labels (0, 1 and 2). These are classed as class labels. Hence we have implemented the three-class classification problem. The target feature contains the numerical values that represent the categorical class identifiers rather than continuous fertility measurements. The classification models are trained to anticipate the corresponding target class based on the physical soil data. In order to guarantee consistency with the dataset, the original class encoding is maintained during model development.

4.2. Exploratory Analysis and Data Visualization

We studied different physicochemical parameters and observed that there is a variation in the characteristics of soil attribute values. Figure 2a presents the soil fertility distribution Classes before adaptive sampling. With fertility Classes 0 and 1 having significantly more samples than Class 2, which is represented by a small number of observations, the results unmistakably show an unequal class distribution. Machine learning algorithms may become biased toward the majority classes as a result of this imbalance, which would decrease their capacity to forecast the minority fertility group. In the next experiment, SMOTE and Borderline-SMOTE were used to improve the representation of minority classes and see how well they worked at making the machine learning models better at making predictions overall.
Figure 2. (a) Distribution of soil fertility classes before adaptive sampling for soil fertility. (b) Feature correlation matrix for soil fertility.
Figure 2b presents the correlation matrix for soil fertility. It discusses the relationship that exists between the 12 physicochemical features in the dataset. It has been observed that some of the pairs have weak correlations and some of them are moderate and others are negative. There is no particularly high correlation between the predictor variables, indicating that the dataset does not include severe multicollinearity. The correlation analysis thus justifies the inclusion of all considered attributes in the following soil fertility prediction framework.

4.3. Comparative Performance Analysis of Machine Learning Models

Table 3 presents the performance metrics for soil fertility prediction. From our experimental observation, it is revealed that SVM achieves the best results in comparison to the other models. The SVM model achieves the highest accuracy of 94.26%, precision of 0.9461, recall of 0.9426, and F1-score of 0.9392. For soil fertility prediction, GB and LightGBM achieved an identical second highest accuracy of 93.44%, followed by other models.
Table 3. Performance metrics of different ML classifier for soil fertility prediction.

4.4. Performance Comparison of Sampling Strategies

Table 4 compares SMOTE and Borderline-SMOTE based on how they address class imbalance in soil fertility prediction. Both generated 735 resampled instances, but SMOTE performed better, achieving a 0.9180 accuracy, 0.9108 weighted F1-score, and 0.8427 MCC, compared with 0.9098, 0.9065, and 0.8274, respectively, for Borderline-SMOTE. Thus, SMOTE provided a better balance between overall accuracy and class-wise performance and was selected as the preferred sampling strategy.
Table 4. Performance comparison of sampling strategies for soil fertility prediction.

4.5. Detailed Performance Analysis of the Random Forest Model

Figure 3a–c summarize the tuned models’ classification and validation performance. Figure 3b presents the classification task performance across the three soil fertility classes (Classes 0, 1, and 2). The updated evaluation takes into account the accuracy, recall, and F1-score for each category to deliver a more comprehensive appraisal of predictive efficacy, encompassing the representation of the minority class. The aggregate metrics are given using the averaging method shown in Table 3. Precision, recall, and F1-score are reported as macro averages across the three classes, assigning equal weight to each class.[ average = “macro”].
Figure 3. (a) Confusion matrix of the tuned RF Model for soil fertility classification. (b) ROC curves of the tuned RF model for multi-class soil fertility prediction. (c) ROC curves of the tuned random forest model for multi-class soil fertility prediction.
The SVM confusion matrix correctly classified 57 Class 0 and 55 Class 1 samples, while the random forest ROC curves achieved AUCs of 0.99 and 0.97 for Classes 0 and 1, respectively. RF training accuracy approached 1.0, whereas cross-validation accuracy increased from 0.63 to 0.96, indicating initial overfitting with limited training data but improved generalization as the training size increased.
Among all the features, N is identified as the top feature that influences soil fertility followed by other features. The dominance of nitrogen and phosphorus suggests that these primary soil nutrients play a significant role in identifying the fertility groups within the dataset under consideration. The feature-important analysis enhance the interpreability machine learning models’ by identifying the soil properties that have the greatest impact on fertility-level prediction.

4.6. Training Dynamics ROC Curves of the Tuned Random Forest Model for Multi-Class Soil Fertility Prediction of the MLP Model

From our experimental observation during the initial stage, the loss curve rapidly decreases and gradually moves towards low values. It indicates an effective optimization of the model. We observed that the validation accuracy reached 100%. Similarly, both training and validation accuracy improved significantly throughout the early epoch before stabilizing at high levels. This study demonstrates that the convergence pattern of MLP effective learn the underlying patterns in the soil during the model training. The Figure 4 presents the training and validation loss and accuracy of the deep learning model across the different epochs for soil fertility prediction.
Figure 4. Training and validation loss and accuracy curves of the MLP model across training epochs.

4.7. Statistical Significance Analysis of Model Performance

This study conducted statistical significance analysis to see if the observed differences in model performance were statistically significant.
Table 5 summarizes the statistical significance tests. McNemar’s test (p = 1.000) showed no significant difference between tuned RF and XGBoost, while ANOVA (p = 0.2232) found no significant difference among the top three models. In contrast, the Friedman test (p < 0.001) confirmed significant performance differences across all 12 ML models. Figure 5 presents the Nemenyi post hoc test for a pairwise comparison of ML model performance. The corresponding p-values indicate statistical significance: lower p-values represent stronger evidence of significant performance differences, whereas higher p-values indicate that the observed differences are not statistically significant.
Table 5. Statistical significance analysis of model performance.
Figure 5. Nemenyi post hoc test results for pairwise comparison of machine learning model performance.
Table 6 compares traditional ML, deep learning (DL), and ensemble approaches for soil fertility prediction. SVM with RBF kernel achieved the highest accuracy (94.26%), while the DL and other compared approaches achieved 93.44%, and the stacking ensemble achieved 92.62%. These results indicate that greater model complexity or classifier integration does not necessarily improve performance, with SVM-RBF providing the best performance for capturing the nonlinear relationships between soil properties and fertility classes.
Table 6. Best ML vs. DL vs. ensemble results.
In this paper, we evaluated the publicly available soil fertility dataset. It contains the soil properties as well as the target features. It contains the three class labels. Our proposed framework suggested using data preprocessing (using the existing dataset from Kaggale), an ML-based classification task, a resampling task and quantitative performance evaluation. In this study, we did not use real-time data collection methods, and we confirm there are no sensors involved in our proposed framework. We did not deploy any sensors to collect data in real-time environments. We used the predictive capabilities of the different models and we do not claim evidence of real-time operational performance.
In future work, we will deploy soil sensors and investigate real-time data transmission.

5. Conclusions

This study proposes an adaptive sampling and ML-based framework for soil fertility prediction and crop recommendation in smart agriculture. Among the evaluated models, SMOTE outperformed Borderline-SMOTE, while SVM achieved the best performance with 94.26% accuracy, 94.61% precision, 94.26% recall, 93.92% F1-score, 0.8889 Kappa, and 0.8912 MCC. Deep MLP and Voting achieved 93.44%, while Stacking achieved 92.62%, showing that higher model complexity does not necessarily improve accuracy. Statistical analysis confirmed significant differences among models (Friedman test, p < 0.001). Sugarcane received the highest crop recommendation score (0.775). Future work will integrate real-time IoT sensing and validate the framework across diverse soils and regions.

Author Contributions

Conceptualization, S.B. and N.P.; methodology, S.B.; software, S.B.; validation, S.B., N.P.; formal analysis, S.B.; investigation, N.P.; resources, S.B.; data curation, S.B.; writing—original draft preparation, S.B.; writing—review and editing, S.B.; visualization, S.B.; supervision, N.P.; project administration N.P.; funding acquisition, N.P. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

In this paper, we utilized the publicly available soil fertility dataset from Kaggale repository, available online: https://www.kaggle.com/datasets/rahuljaiswalonkaggle/soil-fertility-dataset, accessed on 25 January 2026.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Raut, S.S.; Chitre, V. Soil monitoring and testing using IoT for fertility level and crop prediction. Int. J. Res. Appl. Sci. Eng. Technol. 2021, 9, 687–692. [Google Scholar] [CrossRef] [Scilit]
  2. Islam, M.R.; Oliullah, K.; Kabir, M.M.; Alom, M.; Mridha, M.F. Machine learning enabled IoT system for soil nutrients monitoring and crop recommendation. J. Agric. Food Res. 2023, 14, 100880. [Google Scholar] [CrossRef] [Scilit]
  3. Coulibali, Z.; Cambouris, A.N.; Parent, S.-É. Site-specific machine learning predictive fertilization models for potato crops in Eastern Canada. PLoS ONE 2020, 15, e0230888. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  4. Senapaty, M.K.; Ray, A.; Padhy, N. IoT-enabled soil nutrient analysis and crop recommendation model for precision agriculture. Computers 2023, 12, 61. [Google Scholar] [CrossRef] [Scilit]
  5. Pant, J.; Pant, P.; Pant, R.P.; Bhatt, A.; Pant, D.; Juyal, A. Soil quality prediction for determining soil fertility in Bhimtal Block of Uttarakhand (India) using machine learning. Int. J. Anal. Appl. 2021, 19, 91–109. [Google Scholar] [CrossRef] [Scilit]
  6. Terhoeven-Urselmans, T.; Vagen, T.G.; Spaargaren, O.; Shepherd, K.D. Prediction of soil fertility properties from a globally distributed soil mid-infrared spectral library. Soil Sci. Soc. Am. J. 2010, 74, 1792–1799. [Google Scholar] [CrossRef] [Scilit]
  7. Soriano-Disla, J.M.; Janik, L.J.; Viscarra Rossel, R.A.; Macdonald, L.M.; McLaughlin, M.J. The performance of visible, near-, and mid-infrared reflectance spectroscopy for prediction of soil physical, chemical, and biological properties. Appl. Spectrosc. Rev. 2014, 49, 139–186. [Google Scholar] [CrossRef] [Scilit]
  8. Viscarra Rossel, R.A.; Behrens, T.; Ben-Dor, E.; Brown, D.J.; Demattê, J.A.M.; Shepherd, K.D.; Shi, Z.; Stenberg, B.; Stevens, A.; Adamchuk, V.; et al. A global spectral library to characterize the world’s soil. Earth-Sci. Rev. 2016, 155, 198–230. [Google Scholar] [CrossRef] [Scilit]
  9. Morellos, A.; Pantazi, X.-E.; Moshou, D.; Alexandridis, T.; Whetton, R.; Tziotzios, G.; Wiebensohn, J.; Bill, R.; Mouazen, A.M. Machine learning based prediction of soil total nitrogen, organic carbon and moisture content by using VIS-NIR spectroscopy. Biosyst. Eng. 2016, 152, 104–116. [Google Scholar] [CrossRef] [Scilit]
  10. Hengl, T.; Heuvelink, G.B.M.; Kempen, B.; Leenaars, J.G.B.; Walsh, M.G.; Shepherd, K.D.; Sila, A.; MacMillan, R.A.; de Jesus, J.M.; Tamene, L.; et al. Mapping soil properties of Africa at 250 m resolution: Random forests significantly improve current predictions. PLoS ONE 2015, 10, e0125814. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  11. Hengl, T.; Mendes de Jesus, J.; Heuvelink, G.B.M.; Ruiperez Gonzalez, M.; Kilibarda, M.; Blagotić, A.; Shangguan, W.; Wright, M.N.; Geng, X.; Bauer-Marschallinger, B.; et al. SoilGrids250m: Global gridded soil information based on machine learning. PLoS ONE 2017, 12, e0169748. [Google Scholar] [CrossRef]
  12. Brungard, C.W.; Boettinger, J.L.; Duniway, M.C.; Wills, S.A.; Edwards, T.C. Machine learning for predicting soil classes in three semi-arid landscapes. Geoderma 2015, 239–240, 68–83. [Google Scholar] [CrossRef] [Scilit]
  13. Heung, B.; Bulmer, C.E.; Schmidt, M.G. Predictive soil parent material mapping at a regional-scale: A Random Forest approach. Geoderma 2014, 214, 141–154. [Google Scholar] [CrossRef] [Scilit]
  14. Wadoux, A.M.J.-C.; Minasny, B.; McBratney, A.B. Machine learning for digital soil mapping: Applications, challenges and suggested solutions. Earth-Sci. Rev. 2020, 210, 103359. [Google Scholar] [CrossRef] [Scilit]
  15. Longchamps, L.; Mandal, D.; Khosla, R. Assessment of soil fertility using induced fluorescence and machine learning. Sensors 2022, 22, 4644. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  16. Dasgupta, S.; Chakraborty, S.; Weindorf, D.C.; Li, B.; Silva, S.H.G.; Bhattacharyya, K. Influence of auxiliary soil variables to improve PXRF-based soil fertility evaluation in India. Geoderma Reg. 2022, 30, e00557. [Google Scholar] [CrossRef] [Scilit]
  17. Jia, X.; Fang, Y.; Hu, B.; Yu, B.; Zhou, Y. Development of soil fertility index using machine learning and visible-near-infrared spectroscopy. Land 2023, 12, 2155. [Google Scholar] [CrossRef] [Scilit]
  18. Shahzad, A.; Ibrahim, M.; Saleem, R.M.; Zia, S.; Habib, S.; Mahmood, M. Unveiling soil fertility patterns via image analysis and machine learning for accurate crop recommendations. J. Comput. Biomed. Inform. 2024, 011-SII/2024. Available online: https://jcbi.org/index.php/Main/article/view/427 (accessed on 11 July 2026).
  19. Dey, B.; Ferdous, J.; Ahmed, R. Machine learning based recommendation of agricultural and horticultural crop farming in India under the regime of NPK, soil pH and three climatic variables. Heliyon 2024, 10, e25112. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  20. Chawla, N.V.; Bowyer, K.W.; Hall, L.O.; Kegelmeyer, W.P. SMOTE: Synthetic minority over-sampling technique. J. Artif. Intell. Res. 2002, 16, 321–357. [Google Scholar] [CrossRef] [Scilit]
  21. He, H.; Bai, Y.; Garcia, E.A.; Li, S. ADASYN: Adaptive synthetic sampling approach for imbalanced learning. In Proceedings of the IEEE International Joint Conference on Neural Networks, Hong Kong, China, 1–8 June 2008; pp. 1322–1328. [Google Scholar]
  22. Batista, G.E.A.P.A.; Prati, R.C.; Monard, M.C. A study of the behavior of several methods for balancing machine learning training data. SIGKDD Explor. Newsl. 2004, 6, 20–29. [Google Scholar] [CrossRef] [Scilit]
  23. Arangi, D.; Padhy, N. Federated Edge Learning for Distributed Weed Detection in Precision Agriculture Using Multimodal Sensor Fusion. Eng. Proc. 2025, 118, 33. [Google Scholar] [CrossRef] [Scilit]
  24. Behera, H.; Nayak, B.; Kumar Gouda, R.; Padhy, N.; Panigrahi, R.; Mahapatro, P.K. An In-Depth Comparative Analysis of Machine Learning Models for Soil Fertility Prediction. Eng. Proc. 2026, 124, 116. [Google Scholar] [CrossRef] [Scilit]
  25. Mahapatro, P.K.; Panigrahi, R.; Padhy, N.; Behera, S.; Arangi, D. Secure and Sovereign Deep Learning for Plant Disease Detection: A Transfer Learning Approach with DenseNet121. Procedia Comput. Sci. 2026, 282, 389–399. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.