Machine Learning in Agriculture: KNN-Based Classification of Fruits and Vegetables
DOI:
https://doi.org/10.61173/tszzmw78Keywords:
K Nearest Neighbor (KNN), machine learning, image recognitionAbstract
In modern agriculture and the food industry, it is essential to classify fruits and vegetables accurately and efficiently to meet growing consumer demand and reduce post-harvest losses. Traditional manual methods are often labor-intensive and error prone, highlighting the need for automated solutions. This paper discusses the application of the k Nearest Neighbor (KNN) algorithm to fruit and vegetable recognition using image processing technology. In this study, image data sets are used for feature extraction using Directional Gradient Histogram (HOG) and dimensionality reduction using Principal Component Analysis (PCA). The accuracy of KNN model on verification set and test set reaches 97%, which proves its validity. Confusion matrix analysis and F1 score evaluation further revealed the strengths and areas of improvement of the model, particularly in distinguishing visually similar categories. The results show that the integration of artificial intelligence (especially KNN) offers great potential for the automation of agricultural classification tasks. Future studies could combine more advanced models, such as CNNS, with larger datasets to improve accuracy and robustness.
References
[1] Patel K, Patel HB. A comparative analysis of supervised machine learning algorithm for agriculture crop prediction. In2021 fourth international conference on electrical, computer and communication technologies (ICECCT) 2021 Sep 15 (pp. 1-5). IEEE.
[2] Yamaç SS. Reference evapotranspiration estimation with kNN and ANN models using different climate input combinations in the semi-arid environment. Journal of Agricultural Sciences. 2021 Apr 1.
[3] Razavi S, Yalçın H. Plant classification using group of features. In2016 24th Signal Processing and Communication Application Conference (SIU) 2016 May 16 (pp. 1957-1960). IEEE.
[4] Shaik MA, Manoharan G, Prashanth B, Akhil N, Akash A, Reddy TR. Prediction of crop yield using machine learning. InAIP Conference Proceedings 2022 May 24 (Vol. 2418, No. 1). AIP Publishing.
[5] Kaggle, Fruit and Vegetable Image Recognition, 2021, https://www.kaggle.com/datasets/kritikseth/fruit-and-vegetableimage-recognition
[6] Peterson LE. K-nearest neighbor. Scholarpedia. 2009 Feb 21;4(2):1883.
[7] Laaksonen J, Oja E. Classification with learning k-nearest neighbors. InProceedings of international conference on neural networks (ICNN’96) 1996 Jun 3 (Vol. 3, pp. 1480-1483). IEEE.
[8] Keller JM, Gray MR, Givens JA. A fuzzy k-nearest neighbor algorithm. IEEE transactions on systems, man, and cybernetics. 1985 Jul(4):580-5.
[9] Dalal N, Triggs B. Histograms of oriented gradients for human detection. In2005 IEEE computer society conference on computer vision and pattern recognition (CVPR’05) 2005 Jun 20 (Vol. 1, pp. 886-893). Ieee.
[10] Maćkiewicz A, Ratajczak W. Principal components analysis (PCA). Computers & Geosciences. 1993 Mar 1;19(3):303-42.
Downloads
Published
Issue
Section
License
Copyright (c) 2024 by the authors.

This work is licensed under a Creative Commons Attribution 4.0 International License.
