Crop Recommendation Based on Soil and Weather Conditions Using the K-Nearest Neighbors Algorithm - Yuliyanto, Yuliyanto; Sahibu, Supriadi; Imran, Taufik; Arisha, Andriansyah Oktafiandi; Munawirah, Munawirah (Universitas Pancasakti, 2025)
The national food self-sufficiency program demands innovation in optimizing the selection of agricultural commodities based on environmental and weather conditions. This challenge is rooted in a fundamental problem faced by farmers—achieving harmony among soil characteristics, weather patterns, and suitable crops. In support of this initiative, it is necessary to develop a crop recommendation system based on machine learning that utilizes key soil and weather condition parameters. This study employs the K-Nearest Neighbors (KNN) algorithm, which functions by identifying the optimal value of ‘K’ to maximize classification accuracy. The KNN algorithm is implemented in a crop recommendation system to classify 1,100 datasets representing ideal growing conditions for 11 crop types. These datasets were generated using a normal distribution approach with a 5% variation from the mean values, and were validated using a clipping function to ensure the data remained within ideal ranges. The results of this study demonstrate that the KNN algorithm achieves high accuracy 96,67% in utilizing soil and weather parameters to generate crop recommendations. The average probability score for the recommended crops was 83.33%. Based on experimental testing, rice was recommended during the rainy and extreme rainy seasons, soybeans were recommended during the dry season, and mung beans were most suitable during extreme dry conditions.