Accurate assessment of key soil attributes such as soil organic carbon (OC), available phosphorus (P), and available potassium (K) using mid‐infrared spectroscopy (MIRS) is essential for better soil management in precision agriculture. However, the calibration of the portable version of MIRS is more challenging than the benchmark technologies, hence, demanding more efficient modelling methods to provide accurate outcomes. This research aims to use the stacked generalisation machine learning (SG–ML) framework, combining support vector machine (SVM), gradient boosted regression (GBR), and random forest (RF), using linear ridge regression as a meta learner, for predicting OC, P, and K using MIR spectra of 375 soil samples collected from four farms (Flanders, Belgium). The performance of the SG–ML models was compared with the multilayer perceptron (MLP) deep learning (DL) method. Results showed the superiority of the SG–ML method over the corresponding single ML and DL models. The predictive performance of SG–ML using the validation set was excellent for the three soil attributes, with coefficient of determination (R2) and root mean square error (RMSE) values of 0.88% and 0.10%, 0.85 and 4.53 mg 100 g−1, and 0.84 and 3.87 mg 100 g−1 for OC, K, and P, respectively. The performance of DL models were good for OC (R2 = 0.65, and RMSE = 0.17%), poor for K (R2 = 0.58 and RMSE = 7.59 mg 100 g−1), and very poor for P (R2 = 0.46, and RMSE = 6.57 mg 100 g−1). The SG–ML reduced the prediction RMSE by 10% to 31%, compared with the single ML (SVM, RF, and GBR) models. In summary, the proposed stacking method is a powerful modelling tool for the accurate prediction of key soil attributes using portable MIRS.
Highlights
Machine learning (ML) and deep learning (DL) models were developed based on mid‐infrared soil spectra.
The stacked generalisation ML (SG–ML) was compared with ML and DL for predicting OC, P, and K.
SG–ML models outperformed ML (GBR, RF, and SVM) and deep learning (DL) models.
The SG–ML models significantly decreased RMSE by 10% to 31% compared with the single ML models.