A Comparative Analysis of Machine Learning Models for Crop Recommendation using Explainable AI

Crop selection is a critical decision in agriculture because it directly affects yield, resource utilization, and economic sustainability. Conventional crop recommendations rely on human experience and agricultural norms, but they do not take into account variability in soil nutrients and climate factors. In this paper, a comparative analysis of machine learning algorithms for recommendation of crops based on soil and climate parameters will be done. Features such as nitrogen, phosphorus, potassium, temperature, humidity, pH, and rainfall are used in order to predict appropriate crops. In order to enhance the efficiency of the algorithm, data preprocessing, feature engineering, train–test splitting, feature scaling, and Synthetic Minority Over-sampling Technique (SMOTE) are implemented. Six machine learning models have been compared: Random Forest, XGBoost, Logistic Regression, CatBoost, Explainable Boosting Machine (EBM), and TabNet. Metrics for comparison of these models include accuracy, precision, recall, F1-score, confusion matrix, and ROC–AUC. To enhance the interpretability of the results, explainable AI methods, including SHAP, Permutation Feature Importance, and LIME, are implemented. It was found that the Random Forest model performed better than other models, and the results for XGBoost, CatBoost, and TabNet were competitive.