Performance of K-Nearest Neighbors and Advanced Metaheuristic Algorithms for Feature Selection in Classifying the Purity of Civet Coffee
DOI:
https://doi.org/10.57152/malcom.v6i1.2345Keywords:
Advanced Metaheuristic Algorithms, Civet Coffee, Feature Selection, K-Nearest NeighborsAbstract
Various studies have shown that feature selection can improve classification accuracy, particularly in agriculture. However, most of these studies still use conventional metaheuristic algorithms, which have certain limitations, including a tendency to get stuck in local optima. Therefore, this study explores the potential of advanced metaheuristic algorithms for selecting colour and texture features to classify the purity of civet coffee. This study used k-Nearest Neighbour (K-NN) model optimized with several advanced metaheuristic algorithms, i.e. Bare Bones Particle Swarm Optimisation (BBPSO), Modified Generalised Flower Pollination Algorithm (MGFPA), Enhanced Salp Swarm Algorithm (ESSA), Improved Salp Swarm Algorithm (ISSA), and Two-Stage Modified Grey Wolf Optimizer (TMGWO). The results show that feature selection can improve model accuracy. The best model was obtained from a combination of K-NN and TMGWO with an accuracy of 0.981, precision of 0.982, recall of 0.981, F1-Score of 0.981, and Area Under Curve (AUC) close to 1 with three selected features, i.e. blue correlation, s_hsl_correlation, and s_hsv_correlation. Furthermore, the results of this study indicate that the development of advanced metaheuristic algorithms can overcome the weaknesses of conventional algorithms, as demonstrated by improvements in classification model accuracy and the number of selected features.
Downloads
References
M. T. Rahman, S. Ferdous, M. S. Jenin, T. R. Mim, M. Alam, and M. R. Al Mamun, “Characterization of tea (Camellia sinensis) granules for quality grading using computer vision system,” J. Agric. Food Res., vol. 6, p. 100210, Dec. 2021, doi: 10.1016/j.jafr.2021.100210.
G. Ren, N. Gan, Y. Song, J. Ning, and Z. Zhang, “Evaluating Congou black tea quality using a lab-made computer vision system coupled with morphological features and chemometrics,” Microchem. J., vol. 160, p. 105600, 2021.
R. Selvanarayanan, S. Rajendran, and Y. Alotaibi, “Early Detection of Colletotrichum Kahawae Disease in Coffee Cherry Based on Computer Vision Techniques,” Comput. Model. Eng. Sci., vol. 139, no. 1, pp. 759–782, 2024, doi: 10.32604/cmes.2023.044084.
D. S. Leme, S. A. da Silva, B. H. G. Barbosa, F. M. Borém, and R. G. F. A. Pereira, “Recognition of coffee roasting degree using a computer vision system,” Comput. Electron. Agric., vol. 156, pp. 312–317, Jan. 2019, doi: 10.1016/j.compag.2018.11.029.
H. Zhou, Y. Xin, and S. Li, “A diabetes prediction model based on Boruta feature selection and ensemble learning,” BMC Bioinformatics, vol. 24, no. 1, p. 224, 2023.
D. Theng and K. K. Bhoyar, “Feature selection techniques for machine learning: a survey of more than two decades of research,” Knowl. Inf. Syst., vol. 66, no. 3, pp. 1575–1637, 2024.
M. A. Khan et al., “Multimodal brain tumor classification using deep learning and robust feature selection: A machine learning application for radiologists,” Diagnostics, vol. 10, no. 8, p. 565, 2020.
A. P. M. S. Hamdard and A. P. H. Lodin, “Effect of Feature Selection on the Accuracy of Machine Learning Model,” Int. J. Multidiscip. Res. Anal., vol. 06, no. 09, Sep. 2023, doi: 10.47191/ijmra/v6-i9-66.
A. Newaz and S. Muhtadi, “Performance Improvement of Heart Disease Prediction by Identifying Optimal Feature Sets Using Feature Selection Technique,” in 2021 International Conference on Information Technology (ICIT), Jul. 2021, pp. 446–450, doi: 10.1109/ICIT52682.2021.9491739.
S. Widyaningtyas, M. Arwani, S. Sucipto, and Y. Hendrawan, “Filter Feature Selection for Detecting Mixture, Total Phenol, and pH of Civet Coffee,” Int. J. Artif. Intell. Robot., vol. 6, no. 2, pp. 75–82, 2024.
A. Darwish, “Bio-inspired computing: Algorithms review, deep analysis, and the scope of applications,” Futur. Comput. Informatics J., vol. 3, no. 2, pp. 231–246, 2018.
E. T. Yasin et al., “Optimized feature selection using gray wolf and particle swarm algorithms for corn seed image classification,” J. Food Compos. Anal., vol. 145, p. 107738, Sep. 2025, doi: 10.1016/j.jfca.2025.107738.
X. Song, Y. Zhang, D. Gong, and X. Sun, “Feature selection using bare-bones particle swarm optimization with mutual information,” Pattern Recognit., vol. 112, p. 107804, 2021.
H. Mohammadzadeh and F. S. Gharehchopogh, “A novel hybrid whale optimization algorithm with flower pollination algorithm for feature selection: Case study Email spam detection,” Comput. Intell., vol. 37, no. 1, pp. 176–209, 2021.
M. Ansari Shiri and N. Mansouri, “Hybrid Filter-Wrapper Feature Selection using Modified Flower Pollination Algorithm,” Comput. Knowl. Eng., vol. 8, no. 2, pp. 55–74, 2025.
M. Barhoush, B. H. Abed-alguni, and N. E. A. Al-qudah, “Improved discrete salp swarm algorithm using exploration and exploitation techniques for feature selection in intrusion detection systems,” J. Supercomput., vol. 79, no. 18, pp. 21265–21309, Dec. 2023, doi: 10.1007/s11227-023-05444-4.
H. Zamani, “Evolutionary salp swarm algorithm with multi-search strategies and advanced memory mechanism for solving global optimization and complex engineering problems,” Sci. Rep., vol. 15, no. 1, p. 33934, Sep. 2025, doi: 10.1038/s41598-025-09345-9.
A. E. Hegazy, M. A. Makhlouf, and G. S. El-Tawel, “Improved salp swarm algorithm for feature selection,” J. King Saud Univ. - Comput. Inf. Sci., vol. 32, no. 3, pp. 335–344, Mar. 2020, doi: 10.1016/j.jksuci.2018.06.003.
C. Shen and K. Zhang, “Two-stage improved Grey Wolf optimization algorithm for feature selection on high-dimensional classification,” Complex Intell. Syst., vol. 8, no. 4, pp. 2769–2789, 2022.
S. Widyaningtyas and M. Arwani, “Color Feature Selection Optimized with Bio inspired Algorithms in Classify Purity of Palm Civet Coffee,” J. Teknol. Inf. dan Terap., vol. 12, no. 1, 2025.
S. Widyaningtyas, S. Arwani, Muhammad, Sucipto, and Y. Hendrawan, “Improving the accuracy of green bean palm civet coffee purity classification using wrapper feature selection,” Coffee Sci. 1984-3909, vol. 20, pp. e202277–e202277, 2025.
A. Solak, A. Onat, and O. Kilinç, “An Improved Bare Bones Particle Swarm Optimization Algorithm Based on Sequential Update Mechanism and a Modified Structure,” IEEE Access, vol. 13, pp. 4789–4814, 2025, doi: 10.1109/ACCESS.2025.3525603.
J. Guo and Y. Sato, “A Dynamic Reconstruction Bare Bones Particle Swarm Optimization Algorithm,” in 2018 IEEE Congress on Evolutionary Computation (CEC), Jul. 2018, pp. 1–6, doi: 10.1109/CEC.2018.8477883.
J. Guo and Y. Sato, “A hierarchical bare bones particle swarm optimization algorithm,” in 2017 IEEE International Conference on Systems, Man, and Cybernetics (SMC), Oct. 2017, pp. 1936–1941, doi: 10.1109/SMC.2017.8122901.
M. K. Y. Shambour, A. A. Abusnaina, and A. I. Alsalibi, “Modified global flower pollination algorithm and its application for optimization problems,” Interdiscip. Sci. Comput. Life Sci., vol. 11, no. 3, pp. 496–507, 2019.
V. Kansal and J. S. Dhillon, “Emended salp swarm algorithm for multiobjective electric power dispatch problem,” Appl. Soft Comput., vol. 90, p. 106172, May 2020, doi: 10.1016/j.asoc.2020.106172.
H. Faris, S. Mirjalili, I. Aljarah, M. Mafarja, and A. A. Heidari, “Salp Swarm Algorithm: Theory, Literature Review, and Application in Extreme Learning Machines,” 2020, pp. 185–199.
S. Mirjalili, A. H. Gandomi, S. Z. Mirjalili, S. Saremi, H. Faris, and S. M. Mirjalili, “Salp Swarm Algorithm: A bio-inspired optimizer for engineering design problems,” Adv. Eng. Softw., vol. 114, pp. 163–191, Dec. 2017, doi: 10.1016/j.advengsoft.2017.07.002.
M. Al-Shabi, C. Ghenai, M. Bettayeb, F. Faraz Ahmad, and M. El Haj Assad, “Estimating PV models using multi-group salp swarm algorithm,” IAES Int. J. Artif. Intell., vol. 10, no. 2, p. 398, Jun. 2021, doi: 10.11591/ijai.v10.i2.pp398-406.
S. Ben Chaabane, A. Belazi, S. Kharbech, A. Bouallegue, and L. Clavier, “Improved Salp Swarm Optimization Algorithm: Application in Feature Weighting for Blind Modulation Identification,” Electronics, vol. 10, no. 16, p. 2002, Aug. 2021, doi: 10.3390/electronics10162002.
L. I. Wong, M. H. Sulaiman, M. R. Mohamed, and M. S. Hong, “Grey Wolf Optimizer for solving economic dispatch problems,” in 2014 IEEE International Conference on Power and Energy (PECon), Dec. 2014, pp. 150–154, doi: 10.1109/PECON.2014.7062431.
P. Cunningham and S. J. Delany, “K-nearest neighbour classifiers-a tutorial,” ACM Comput. Surv., vol. 54, no. 6, pp. 1–25, 2021.
C. Bai, T. Xiao, Y. Chen, H. Wang, F. Zhang, and X. Gao, “Faster-LIO: Lightweight tightly coupled LiDAR-inertial odometry using parallel sparse incremental voxels,” IEEE Robot. Autom. Lett., vol. 7, no. 2, pp. 4861–4868, 2022.
U. Pujianto, A. P. Wibawa, and M. I. Akbar, “K-Nearest Neighbor (K-NN) based missing data imputation,” in 2019 5th International Conference on Science in Information Technology (ICSITech), 2019, pp. 83–88.
M. Afshar and H. Usefi, “Optimizing feature selection methods by removing irrelevant features using sparse least squares,” Expert Syst. Appl., vol. 200, p. 116928, 2022.
F. F. L. dos Santos, J. T. F. Rosas, R. N. Martins, G. de M. Araújo, L. de A. Viana, and J. de P. Gonçalves, “Quality assessment of coffee beans through computer vision and machine learning algorithms,” 2020.
M. García, J. E. Candelo-Becerra, and F. E. Hoyos, “Quality and defect inspection of green coffee beans using a computer vision system,” Appl. Sci., vol. 9, no. 19, p. 4195, 2019.
N. O. Adiwijaya and R. Sarno, “Specialty Coffees Classification Utilizes Feature Selection and Machine Learning,” in 2nd International Conference on Neural Networks and Machine Learning 2023 (ICNNML 2023), 2024, pp. 94–101.
S. WIDYANINGTYAS and M. ARWANI, “Color Feature Selection Optimized with Bio-Inspired Algorithms in Classify Purity of Luwak Coffee,” 2025.
M. Fahmy Amin, “Confusion Matrix in Binary Classification Problems: A Step-by-Step Tutorial,” J. Eng. Res., vol. 6, no. 5, pp. 0–0, Dec. 2022, doi: 10.21608/erjeng.2022.274526.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2025 Shinta Widyaningtyas, Muhammad Arwani, Ririn Fatma Nanda

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Copyright © by Author; Published by Institut Riset dan Publikasi Indonesia (IRPI)
This Indonesian Journal of Machine Learning and Computer Science is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

















