Multi-classifier benchmark performance
Table 6 presents all ten classifier results. Every model achieved CV-test gap ≤5%, confirming absence of pathological overfitting. Random Forest achieved the best performance with CV F1 = 96.55% and Test F1 = 96.93%, AUC = 0.9995 and Gap = 0.38%. The 95% confidence interval (CV F1±1.96 × CV Std/√K) = 96.55%±0.178%, confirming the 0.37 percentage point advantage over gradient boosting (96.18%) is statistically reliable and not attributable to fold-level sampling variation. Gradient boosting, light GBM (96.14%) and XGBoost (96.11%) formed a closely competing high-performance group, while KNN (87.92%) and Logistic Regression (85.81%) performed substantially worse, confirming that instance-based and linear models are unsuitable for this dataset. Fold-level variability is reported in Table 6.
The confusion matrix (Fig 5) confirms high per-class accuracy across all 33 crop classes, while learning curves (Fig 6) show convergence at approximately 70% of training data with a generalisation gap of 3.43%.
Statistical significance analysis
Friedman-nemenyi statistical analysis
The Friedman test yielded χ
2=59.23 (p=1.89×10
-9, df=9), strongly rejecting the null hypothesis of equal classifier performance and confirming that observed differences are not due to chance.
Nemenyi post-hoc analysis (CD=3.428) identified three distinct performance clusters. The top cluster random forest (rank 1.000), gradient boosting (3.000), LightGBM (3.143) and XGBoost (3.571)-was statistically equivalent (all Nemenyi p≥0.838). An intermediate group comprised CatBoost, extra trees, decision tree and naive bayes, while KNN and logistic regression formed an inferior cluster with significant performance degradation relative to the top models (p<0.03). Pairwise results are in Fig 3.
Random forest was selected as optimal through the composite selection criterion, confirming its suitability for agricultural deployment under data variability.
Model selection justification
Random forest achieved the highest composite selection score (98.236), supported by the lowest CV variability (CV Std=0.240), near-minimal generalisation gap (0.38%) and best Friedman rank (1.000), confirming its selection as the optimal classifier. This represents a departure from equating the best model solely with highest accuracy, emphasising stability and generalisation as equally critical criteria.
Although
Prity et al., (2024) and
Shastri et al., (2025) report higher accuracies (99.31% and 99.27%), these studies use fewer output classes and lack formal statistical validation. A comparative summary of these approaches and the proposed method is presented in Table 7. The proposed approach achieves test F1=97.06% on a more challenging 33-class problem with rigorous statistical testing and multi-criteria selection, making the findings more robust and scientifically grounded.
Hyperparameter optimisation analysis
Optuna TPE identified the optimal configuration at trial 21 (n_estimators=348, max_depth=31, min_samples_ split=12, min_samples_leaf=2, max_features=log2), yielding a marginal gain of +0.08 percentage points in CV F1 (96.55% to 96.63%), reinforcing the well-established hyperparameter robustness of Random Forest on tabular datasets
(Probst et al., 2019).
The flat convergence surface (Fig 4) confirms the default configuration is near pareto-optimal- performance is governed more by dataset quality than hyperparameter tuning, yielding diminishing returns from extensive search.
Final validated performance: CV F1=96.58% ± 0.215%, Test F1=97.06%, AUC=0.9996, Gap=0.47%, confirming strong predictive power, generalisation ability and low overfitting risk with minimal tuning effort.
Feature importance and interpretability
MDI and SHAP analysis (Table 8; Fig 7-8) provide dual-layer interpretation of model decisions. Humidity ranked 1
st in both MDI (0.2573) and SHAP (0.02337), with rainfall ranked 2
nd by MDI and 3
rd by SHAP. Nitrogen and temperature showed moderate importance, while pH and phosphorus ranked lowest in both methods.
A notable discrepancy was observed for potassium (K): ranked 5
th by MDI (0.1084) but 2
nd by SHAP (0.02172). This is consistent with known MDI bias for high-cardinality continuous features
(Strobl et al., 2007) -impurity-based measures underestimate features that influence predictions through magnitude rather than split frequency. SHAP captures this correctly, revealing potassium as a key discriminative feature for crops with similar climatic profiles (
e.g. similar temperature and humidity), an important agronomic insight not visible through MDI alone.
The dual MDI+SHAP framework enhances transparency and provides direct practical guidance for fertiliser management and crop planning in precision agriculture.
Ablation perspective, framework validation and practical implications
An ablation analysis confirms that each framework component serves a distinct purpose: removing the entropy term reduces prediction diversity; removing the stability component increases fold-to-fold variance; removing the generalisation gap penalty increases overfitting risk. Framework strength emerges from their combined balance rather than any individual measure.
The proposed framework is practically deployable. The tuned random forest model generates a single prediction in under one millisecond, making it suitable for lightweight mobile or web-based decision-support applications. Soil input values (N, P, K, pH) can be obtained from low-cost portable soil testing kits, while meteorological inputs (temperature, humidity, rainfall) are accessible via public weather data services such as NASA POWER and OpenWeatherMap, enabling operation without specialist infrastructure in resource-constrained agricultural environments.