Comparative analysis of machine learning models for multi-class crop recommendation using soil and climate features

Climate variability is a major constraint on agricultural production, with potential impacts on yields, soil degradation, and economic security. In order to solve this problem, the present study introduces a crop recommendation framework based on machine learning which considers the soil nutrients (N, P, K) and environmental factors (temp, humidity, rainfall, soil pH). The model is built using the publicly available Crop Recommendation dataset from Kaggle which has 2200 samples divided into 22 balanced classes of crops and no missing values. The data were preprocessed to ensure consistency, including Z-score-based outlier detection, standardization of features, and label encoding. The data set was divided into training (70%), validation (15%) and test (15%) sets and five-fold cross-validation was used to check the robustness of the model and its generalization. Random Forest (RF), XGBoost, LightGBM, Deep Neural Network (DNN) and Multi-Layer Perceptron (MLP) models were implemented and tuned with hyperparameter tuning using grid search. The accuracy, macro precision, macro recall, and macro F1-score were used to assess performance. Experimental results show that XGBoost and LightGBM models perform better than all the other models. The accuracy of XGBoost is 99.27% and that of LightGBM is nearly the same with 99.22%, which is also very stable in the cross-validation, thus the excellent generalization capability. Cross-validation scores (0.9909, 0.9955, 0.9955, 0.9955, 0.9932) further validate the robustness of ensemble-based approaches. Random Forest has an accuracy of 93% while DNN and MLP have an accuracy of around 98%, which are competitive but less stable than the ensemble methods from trees. The work shows that the optimized gradient boosting is better than deep learning when it comes to structured data from the agricultural domain.The study reveals that gradient boosting models like XGBoost and LightGBM outperformed deep learning models when applied to structured agricultural data sets.The study shows that structured agricultural data sets feature optimized gradient boosting models (XGBoost and LightGBM) that are consistently superior to deep learning models. What is new in this work is that it gives a comprehensive comparative analysis of various ensemble models and deep learning models and gives a strong evidence to choose one model for a crop recommendation system. Real-world noisy data and dynamic agricultural datasets like soil moisture, pest incidence, and temporal variability would be incorporated into the future to improve the applicability of the data.

Authors

Institutions

Publication Details

Journal
Scientific Reports
Published
2026-11-25
DOI
https://doi.org/10.1038/s41598-026-79367-4
Primary Topic
Smart Agriculture and AI
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
article

Comparative analysis of machine learning models for multi-class crop recommendation using soil and climate features

Chirag Joshi, Saghar Ganji, Bibek Kumar, Vinay Agrawal et al.
Scientific Reports
Smart Agriculture and AI
article

Comparative analysis of machine learning models for multi-class crop recommendation using soil and climate features

Chirag Joshi, Saghar Ganji, Bibek Kumar, Vinay Agrawal, Jashvant Kumar
article en

Abstract

Climate variability is a major constraint on agricultural production, with potential impacts on yields, soil degradation, and economic security. In order to solve this problem, the present study introduces a crop recommendation framework based on machine learning which considers the soil nutrients (N, P, K) and environmental factors (temp, humidity, rainfall, soil pH). The model is built using the publicly available Crop Recommendation dataset from Kaggle which has 2200 samples divided into 22 balanced classes of crops and no missing values. The data were preprocessed to ensure consistency, including Z-score-based outlier detection, standardization of features, and label encoding. The data set was divided into training (70%), validation (15%) and test (15%) sets and five-fold cross-validation was used to check the robustness of the model and its generalization. Random Forest (RF), XGBoost, LightGBM, Deep Neural Network (DNN) and Multi-Layer Perceptron (MLP) models were implemented and tuned with hyperparameter tuning using grid search. The accuracy, macro precision, macro recall, and macro F1-score were used to assess performance. Experimental results show that XGBoost and LightGBM models perform better than all the other models. The accuracy of XGBoost is 99.27% and that of LightGBM is nearly the same with 99.22%, which is also very stable in the cross-validation, thus the excellent generalization capability. Cross-validation scores (0.9909, 0.9955, 0.9955, 0.9955, 0.9932) further validate the robustness of ensemble-based approaches. Random Forest has an accuracy of 93% while DNN and MLP have an accuracy of around 98%, which are competitive but less stable than the ensemble methods from trees. The work shows that the optimized gradient boosting is better than deep learning when it comes to structured data from the agricultural domain.The study reveals that gradient boosting models like XGBoost and LightGBM outperformed deep learning models when applied to structured agricultural data sets.The study shows that structured agricultural data sets feature optimized gradient boosting models (XGBoost and LightGBM) that are consistently superior to deep learning models. What is new in this work is that it gives a comprehensive comparative analysis of various ensemble models and deep learning models and gives a strong evidence to choose one model for a crop recommendation system. Real-world noisy data and dynamic agricultural datasets like soil moisture, pest incidence, and temporal variability would be incorporated into the future to improve the applicability of the data.

Scientific Reports
Shiraz University of Technology (IR), Symbiosis International (Deemed University) (IN), Sharda University (IN)
Smart Agriculture and AI
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon