Performance Assessment of K-Nearest Neighbors and Naive Bayes Classifiers in Apple Quality Prediction for Data-Driven Agriculture
Keywords:
Apple quality prediction, machine learning, KNN, naïve bayes classifier, automated fruit grading systemAbstract
Background and Objective: Accurate classification of fruit quality is essential in modern agriculture to enhance grading systems, improve supply chain efficiency and ensure consumer satisfaction. This study aimed to perform a comparative evaluation of two machine learning algorithms-K-Nearest Neighbors (KNN) and Naive Bayes-for predicting apple quality based on physical and chemical attributes.
Materials and Methods: A dataset comprising 4,000 apple samples was obtained from Kaggle and pre-processed through data cleaning and normalization to ensure a balanced distribution of “Good” and “Bad” quality categories. Both KNN and Naive Bayes models were developed using a supervised learning approach and trained on 70% of the data, while the remaining 30% was used for testing. Model performance was evaluated using standard classification metrics, including accuracy, precision, recall and F1-score.
Results: The comparative analysis revealed that the KNN model outperformed the Naive Bayes classifier. KNN achieved a precision of 90.12% and a weighted F1-score of 0.90, whereas Naive Bayes attained a precision of 88.00% and an F1-score of 0.88. Furthermore, KNN exhibited superior precision and recall across both quality classes, demonstrating its effectiveness in handling correlated features such as sweetness, ripeness and acidity. In contrast, Naive Bayes showed higher misclassification rates, likely due to its assumption of feature independence and reduced performance with overlapping feature distributions.
Conclusion: The findings indicate that KNN is a more reliable and robust algorithm for apple quality prediction compared to Naive Bayes. Its ability to manage correlated variables makes it particularly suitable for agricultural datasets. The study highlights the potential application of KNN in developing automated fruit grading systems, thereby supporting smart farming practices through enhanced efficiency, reduced economic losses and improved data-driven decision-making in agricultural production and supply chains.
Downloads
Published
Issue
Section
License
Copyright (c) 2025 Lykzelle Mae C. Padasas, Jose C. Agoylo Jr., Efren I. Balaba, Jimson A. Olaybar

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