The Critical Role of Contextual Feature Engineering in Machine Learning-Based Soil Nutrient Sensing
The Critical Role of Contextual Feature Engineering in Machine Learning-Based Soil Nutrient Sensing
Dana Ghanama,Mohammed Al-Hubaishi
Abstract
This study evaluates the performance of a 3D printed cuvette sensor for measuring the primary macronutrients in soil: nitrogen, phosphorus, and potassium. Our experiments showed the best model to be Random Forest, and that additional contextual metadata from the samples, such as soil type and dilution factor, significantly increased model performance because we approach the problem from two sides: (i) classifying the nutrient levels as Low, Medium, and High and (ii) predicting the exact concentration of the nutrients. Both approaches showed clear improvements in predictive accuracy, and the classification accuracy for all three nutrients were substantial, with nitrogen at 73%, phosphorus at 83%, and potassium at 77%, meaning that the sensor can be used for practical, field-friendly classification. The nitrogen and potassium showed excellent and good fit respectively, with (R2=0.9197) and (R2=0.7926), meaning that accurate quantification is possible with additional contextual information; however, the phosphorus showed the best classification accuracy but poor regression fit, with an (R2=−0.0468), indicating that although phosphorus levels can be separated into classes, the sensor reading-concentration mapping is weak or highly non-linear. This difference in performance has practical implications for future sensor design and modeling strategies for quantitative phosphorus measurement.
