A Machine Learning-Based Crop Recommendation and Planting Advisory System Using Environmental and Soil Data
Abstract
Crop selection is an important agricultural decision because crop suitability depends on a combination of soil, climatic, and environmental conditions. This study developed a machine learning-based crop recommendation and planting advisory system using environmental and soil data. The study investigated the suitability of four supervised learning algorithms: Random Forest, Extreme Gradient Boosting (XGBoost), Light Gradient Boosting Machine (LightGBM), and Artificial Neural Network. The dataset was preprocessed and extended through feature engineering, including NPK Mean, Temperature-Humidity Index, soil pH category, and rainfall level, to provide additional representation of agronomic conditions. Model performance was assessed using accuracy, precision, recall, and F1-score following hyperparameter optimisation and five-fold cross-validation. XGBoost produced the strongest overall performance on the independent test set, achieving 77.48% accuracy, 77.80% precision, 77.48% recall, and a 77.19% F1-score, and was therefore selected for deployment. To extend the system beyond offline prediction, Google Earth Engine was integrated to obtain location-based soil information, while the OpenWeatherMap API provided current environmental and weather data. SHapley Additive exPlanations (SHAP) were incorporated to explain the factors contributing to individual crop predictions. The resulting system was deployed as an interactive Streamlit application that supports both manual and location-based recommendations and provides prediction confidence, alternative crop recommendations, explanations, and planting advice. The study demonstrates the potential of combining machine learning, environmental data integration, and explainability within a practical crop recommendation and planting advisory framework.