An Interpretable Machine Learning Approach for Soil Fertility Prediction from NPK and pH
Year: 2026
Type: article
Abstract: Soil fertility assessment is central to sustaining agricultural productivity, because the availability of nutrients such as Nitrogen (N), Phosphorus (P) and Potassium (K), together with soil pH, directly governs crop growth and yield. Conventional laboratory-based soil testing is accurate but slow, costly and dependent on specialised equipment and trained personnel, which limits how often farmers, particularly smallholders, can monitor their fields. Machine learning offers a faster, data-driven alternative for estimating soil fertility from routinely measured nutrient parameters. This paper presents a supervised learning approach that classifies soil samples into Low, Medium and High fertility classes using N, P, K and pH as input features. Two tree-based classifiers are implemented and compared: a Decision Tree, chosen for its transparent and easily interpretable decision rules, and a Random Forest, an ensemble of decision trees that reduces variance and the risk of overfitting. The workflow covers data collection, preprocessing, feature selection, model training and evaluation using accuracy, precision, recall and F1-score. Descriptive statistics, box plot analysis and correlation analysis are used to characterise the dataset before modelling, and feature importance scores are used to examine the contribution of each soil parameter. The experimental results show that both classifiers perform well and that the Random Forest achieves higher accuracy, precision and recall than the Decision Tree. The proposed approach provides a low-cost, interpretable decision-support tool for soil management and precision agriculture.
Language: English
Topic: Smart Agriculture and AI
Subfield: Plant Science
Domain: Life Sciences
Open Access status: green
OpenAlex ID: W7225451216
FWCI:
Cites:
Cited by:
Related to:
