Performance Assessment of K-Nearest Neighbors and Naive Bayes Classifiers in Apple Quality Prediction for Data-Driven Agriculture

Authors

  • Lykzelle Mae C. Padasas BSIT Department, Southern Leyte State University, Tomas Oppus Campus, Tomas Oppus, Southern Leyte 6605, Philippines
  • Jose C. Agoylo Jr. ORCiD BSIT Department, Southern Leyte State University, Tomas Oppus Campus, Tomas Oppus, Southern Leyte 6605, Philippines
  • Efren I. Balaba ORCiD BSIT Department, Southern Leyte State University, Tomas Oppus Campus, Tomas Oppus, Southern Leyte 6605, Philippines
  • Jimson A. Olaybar ORCiD FCSIT Department, Southern Leyte State University, Main Campus, Sogod, Southern Leyte 6606, Philippines

Keywords:

Apple quality prediction, machine learning, KNN, naïve bayes classifier, automated fruit grading system

Abstract

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

2025-11-25

Issue

Section

Research Articles

How to Cite

[1]
L. M. Padasas, J. J. Agoylo, E. Balaba, and J. Olaybar, “Performance Assessment of K-Nearest Neighbors and Naive Bayes Classifiers in Apple Quality Prediction for Data-Driven Agriculture”, Insights Comput. Sci., vol. 1, pp. 1–9, Nov. 2025, Accessed: Dec. 01, 2025. [Online]. Available: https://acadpub.com/ics/article/view/performance-assessment-knn-naive-bayes-apple-quality-prediction