Fruit Classification Based on Color, Size, and Weight Using the K-Nearest Neighbor (K-NN) Algorithm

Main Article Content

Ervina Kartika Sari
Novisca Indrian
Nurul Hidayah
Samsudin

Abstract

The development of information technology has encouraged the integration of artificial intelligence in object identification and classification, including in fruit processing industries. This study applies the K-Nearest Neighbor (K-NN) algorithm to classify fruit types based on three main features: color, size, and weight. K-NN is selected due to its simplicity, ability to handle numerical data, and stable performance on small to medium-sized datasets. The dataset consists of apples, oranges, and grapes with different physical characteristics. The research stages include data collection, preprocessing, normalization using Min-Max Scaler, data splitting, model training, and evaluation using a confusion matrix and accuracy. The results indicate that k = 5 achieves the highest accuracy of 93%, proving that color, size, and weight are effective indicators for fruit classification. This study is expected to support the development of automated fruit-sorting systems that are faster, more efficient, and accurate.

Article Details

Section
Articles

References

[1] M. S. Irfanuddin, “Klasifikasi Tingkat Kematangan Belimbing Madu Berdasarkan Karakteristik Warna Menggunakan Algoritma K-Nearest Classification Of Maturity Level Of Honey Martumber Based On Color Characteristics Using The K-Nearest Neighbor Algorithm,” vol. 4, no. 2, 2024, doi: 10.24176/detika.v4i2.12804.

[2] L. Farokhah and P. Korespondensi, “Implementasi K-Nearest Neighbor Untuk Klasifikasi Bunga Implementation Of K-Nearest Neighbor For Flower Classification With Extraction Of Rgb Color Features,” vol. 7, no. 6, 2020, doi: 10.25126/jtiik.202072608.

[3] W. Saputro, D. B. Sumantri, S. Tinggi, I. Komputer, and C. Karya, “Digital Image Implementation In Grape Classification With K-,” vol. 5, pp. 248–253, 2022.

[4] Y. Reswan, R. Toyib, H. Witriyono, and A. Anggraini, “Klasifikasi Tingkat Kematangan Buah Nanas Berdasarkan Fitur Warna Menggunakan Metode K – Nearest Neighbor ( KNN ),” vol. 20, no. 1, pp. 280–287, 2024.

[5] F. Yusuf, A. L. Fadillah, and M. R. Naufal, “K-Nearest Neighbor Untuk Klasifikasi Jenis Buah Berdasarkan Berat, Tinggi, dan Lebar,” vol. 9, no. 10, pp. 703–708, 2023.

[6] V. N. Juli and P. Astuti, “Computer Science ( CO-SCIENCE ) Klasifikasi Kualitas Buah Apel Dengan Algoritma K-Nearest Neighbor ( K-NN ) Menggunakan Bahasa Pemrograman Python,” vol. 4, no. 2, pp. 127–132, 2024.

[7] S. Nurjanah, A. Ramadhan, dan M. H. Kurniawan, “Klasifikasi Jenis Buah Tomat Menggunakan Algoritma K-Nearest Neighbor dan Support Vector Machine,” pp. 800–807, 2025.

[8] R. Firmansyah dan I. P. Sari, “Klasifikasi Tingkat Kematangan Buah Sawit Berdasarkan Ekstraksi Fitur RGB dan GLCM Menggunakan Metode K-NN,” vol. 22, pp. 457–466, 2023.

[9] S. Kardena, F. Izzati, and S. Jakarta, “Classification of Coconut Fruit Quality Using The K-Nearest Neighbour ( K-NN ) Method Based on Feature Extraction : Color ,” vol. 18, no. 1, pp. 143–156, 2025.

[10] W. W. Widiyanto, E. Purwanto, and K. Neighbor, “Classification Of Mango Fruit Quality Based On Texture Characteristics Of Glcm ( Gray Level Co-Occurrence Matrices ) With Algorithm K-NN ( K-NEAREST NEIGHBORS ),” vol. 20, no. 1, pp. 1–10, 2019.

[11] S. Yao, “Machine Learning in Agriculture : KNN-Based Classification of Fruits and Vegetables”.

[12] E. Aenun, N. Munfaati, and A. Witanti, “Klasifikasi Buah dan Sayuran Segar atau Busuk Menggunakan Convolutional Neural Network,” vol. 9, no. 1, pp. 27–38, 2024.

[13] C. Aditya, N. Fadlilah, S. Surorejo, and Z. Arif, “Klasifikasi Jenis Buah Apel Menggunakan Algoritma Convolutional Neural Network,” vol. 4, no. 3, pp. 5201–5208, 2025.

[14] I. H. Ikasari, P. Rosyani, and R. Amalia, “Klasifikasi Jenis Buah Menggunakan Metode CNN,” vol. 4, no. 2, pp. 5451–5458, 2025.

[15] M. Muchtar et al., “Perbandingan Metode K-NN dan SVM untuk Klasifikasi Kematangan Buah Mangga Berdasarkan Citra HSV dan Fitur Statistik” vol. 12, no. 2, pp. 876–884, 2024.

[16] Y. Setiawan, W. Astuti, and M. R. R. Saelan, “Classification for Papaya Fruit Maturity Level With Convolutional Neural Network,” vol. 5, no. 3, 2023.

[17] V. N. Juli, A. Ollivia, and C. Pratiwi, “Klas ifikasi Jenis Anggur Berdasarkan Bentuk Daun Menggunakan Convolutional Neural Network Dan K-Nearest Neighbor,” vol. 3, no. 2, 2023.

[18] K. Kematangan, B. Apel, B. Warna, and M. Metode, “Classification of apple maturity based on color using the K-Nearest Neighboor ( KNN ) method,” vol. 21, no. 1, pp. 55–64, 2024, doi: 10.31515/telematika.v21i1.11773.

[19] S. Informatika et al., “Klasifikasi Kematangan Buah Apel dengan Ekstraksi Fitur Haralick dan KNN,” vol. 1, pp. 1085–1092, 2023.

[20] M. K. Neighbors, N. Wijaya, and A. Ridwan, “Klasifikasi Jenis Buah Apel Dengan,” vol. 08, pp. 74–78, 2019.

[21] V. N. Juli and P. Astuti, “Computer Science ( CO-SCIENCE ) Klasifikasi Kualitas Buah Apel Dengan Algoritma K-Nearest Neighbor ( K-NN ) Menggunakan Bahasa Pemrograman Python,” vol. 4, no. 2, pp. 127–132, 2024.