Optimizing crop classification using K-Nearest Neighbors
Abstract
Food security is a critical global challenge, exacerbated by population growth, climate change, and resource scarcity. This chapter aims to develop and evaluate a machine learning model for classifying crops based on key soil factors, including nitrogen (N), phosphorus (P), potassium (K), pH, electrical conductivity (EC), along with trace elements such as copper (Cu), iron (Fe), manganese (Mn), and zinc (Zn). Using the k-Nearest Neighbors (k-NN) algorithm, the model was trained and tested on a preprocessed dataset, achieving an overall accuracy of 99.17%. The Kappa statistic of 0.99 and sensitivity and specificity values close to 1.0 for all crop classes demonstrate the model’s robustness in accurately classifying crops. These results highlight the effectiveness of the k-NN algorithm in leveraging soil parameters for crop classification, offering valuable insights for precision agriculture. However, minor misclassifications, such as those observed in the mango class, suggest opportunities for further refinement. This chapter underscores the potential of machine learning in transforming agriculture, providing a scalable and practical solution for enhancing food security and promoting sustainable farming practices.
Fields of Study & Subjects
Smart Agriculture and AI
Data Mining and Machine Learning Applications
Artificial Intelligence in Healthcare
Publication details
- Journal / source
- CRC Press eBooks
- Pages
- 88–93
- Publication date
- 3 March 2026
- Language
- EN
- Document type
- Book chapter