Agriculture forms the cornerstone of food security, rural livelihoods, and economic development worldwide. However, traditional crop selection methods in many regions still rely heavily on farmer intuition and outdated practices, which often lead to inefficient resource use, poor yields, and environmental strain. With the advent of artificial intelligence (AI) and machine learning (ML), agriculture is undergoing a data-driven transformation, enabling precision farming techniques that improve productivity while preserving natural resources (Chlingaryan et al., 2018; Kamilaris and Prenafeta-Boldú, 2018).
Machine learning algorithms can analyze large volumes of soil and climate data to extract patterns and generate predictive insights that support more informed agricultural decisions. For instance, Random Forest and other ensemble methods have been proven highly effective in predicting regional and global crop yields under diverse conditions (Jeong et al., 2016). These models outperform traditional statistical methods in terms of accuracy, scalability, and noise resilience in real-world data.
In recent years, researchers and developers have focused on creating intelligent crop recommendation systems that consider key agronomic factors, including soil nutrient levels, pH, rainfall, temperature, and humidity. These parameters directly influence crop suitability and yield outcomes. By processing this data through ML models, such systems offer farmers objective, site-specific recommendations that can guide cultivation decisions and reduce the risk of crop failure (Chlingaryan et al., 2018).
This study introduces an AI-based crop recommendation system that incorporates seven critical input variables: nitrogen (N), phosphorus (P), potassium (K), pH level, temperature (°C), humidity (%), and rainfall (mm). Multiple machine learning models were trained and tested, including Logistic Regression, Decision Trees, K-Nearest Neighbors (KNN), Support Vector Machines (SVM), Naive Bayes, XGBoost, and Random Forests. Among these, the Random Forest classifier achieved the highest prediction accuracy, reaching 98.2 percent.
To make this system accessible and practical for end-users, a web application was developed using Python and Flask, with a responsive and straightforward front-end interface. Users can input local environmental and soil data and receive categorized crop suggestions: Recommended, Slightly Recommended, and Not Recommended. This tool not only supports sustainable agricultural practices but also demonstrates how AI technologies can be effectively translated into field-level solutions for smallholder and commercial farmers alike.