Comparative Evaluation of Hyperparameter Optimization Strategies for k-Nearest Neighbors over Mixed Domain Search Spaces

Meta Kallista, Ig. Prasetya Dwi Wibawa, Heni Widayani

Abstract


k-Nearest Neighbors (KNN) remains a strong baseline due to its simplicity, interpretability, and non-parametric structure; however, its predictive performance is highly sensitive to interacting hyperparameters. This paper studies search-constrained hyperparameter optimization for KNN over a mixed search space comprising an integer neighborhood size, a categorical distance metric, and a continuous Minkowski exponent. Seven tuning strategies are compared under a unified nested validation protocol with standardized preprocessing: grid search, random search, Bayesian optimization, genetic algorithm, surrogate optimization, particle swarm optimization, and grey wolf optimizer. Experiments on diverse public classification datasets from UCI, OpenML, and Kaggle evaluate predictive performance (accuracy, macro-AUC, cross-entropy), validation loss, and runtime. The results indicate that adaptive optimizers generally provide more favorable performance–cost trade-offs than exhaustive grids under limited evaluations, while no single method is uniformly best across all datasets. Rank-based statistical comparisons using non-parametric tests further support the observed differences and motivate practical recommendations for selecting tuning strategies as a function of evaluation search and mixed-domain search-space characteristics.


Keywords


k-Nearest Neighbors; hyperparameter optimization; Bayesian optimization; surrogate optimization; grey wolf optimizer; particle swarm optimization

Full Text:

PDF

References


[1] T. M. Cover and P. E. Hart, “Nearest neighbor pattern classification,” IEEE Transactions on Information Theory, vol. 13, no. 1, pp. 21–27, 1967. DOI: https://doi.org/10.1109/TIT.1967.1053964. URL: https://isl.stanford.edu/~cover/papers/transIT/0021cove.pdf. Accessed: 30 Apr. 2026.

[2] P. K. Syriopoulos, N. G. Kalampalikis, S. B. Kotsiantis, and M. N. Vrahatis, “kNN classification: A review,” Annals of Mathematics and Artificial Intelligence, 2023. DOI: https://doi.org/10.1007/s10472-023-09882-x.

[3] R. K. Halder, M. N. Uddin, M. A. Uddin, S. Aryal, and A. Khraisat, “Enhancing K-nearest neighbor algorithm: A comprehensive review and performance analysis of modifications,” Journal of Big Data, vol. 11, p. 113, 2024. DOI: https://doi.org/10.1186/s40537-024-00973-y.

[4] I. Meiska, S. M. Naf’an, I. P. D. Wibawa, M. Kallista, B. F. Aina, and A. Awaludin, “Improving k-nearest neighbors model using SMOTE with bagging ensemble,” in 2023 IEEE Asia Pacific Conference on Wireless and Mobile (APWiMob), IEEE, 2023, pp. 195–201.

[5] L. Franceschi, M. Donini, V. Perrone, A. Klein, C. Archambeau, M. Seeger, M. Pontil, and P. Frasconi, “Hyperparameter optimization in machine learning,” Foundations and Trends in Machine Learning, vol. 18, no. 6, 2025. DOI: https://doi.org/10.1561/2200000088. URL: https://arxiv.org/abs/2410.22854.

[6] J. Bergstra and Y. Bengio, “Random search for hyper-parameter optimization,” Journal of Machine Learning Research, vol. 13, pp. 281–305, 2012. URL: https://jmlr.org/papers/v13/bergstra12a.html.

[7] J. Snoek, H. Larochelle, and R. P. Adams, “Practical Bayesian optimization of machine learning algorithms,” in Advances in Neural Information Processing Systems, vol. 25, 2012. URL: https://proceedings.neurips.cc/paper/2012/file/05311655a15b75fab86956663e1819cd-Paper.pdf.

[8] D. R. Jones, M. Schonlau, and W. J. Welch, “Efficient global optimization of expensive black-box functions,” Journal of Global Optimization, vol. 13, no. 4, pp. 455–492, 1998. DOI: https://doi.org/10.1023/A:1008306431147.

[9] D. Ha and J. Carstensen, “Automatic hyperparameter tuning of topology optimization algorithms using surrogate optimization,” Structural and Multidisciplinary Optimization, vol. 67, p. 157, 2024. DOI: https://doi.org/10.1007/s00158-024-03850-7.

[10] J. Kennedy and R. Eberhart, “Particle swarm optimization,” in Proceedings of the IEEE International Conference on Neural Networks, IEEE, 1995, pp. 1942–1948. DOI: https://doi.org/10.1109/ICNN.1995.488968.

[11] S. Mirjalili, S. M. Mirjalili, and A. Lewis, “Grey wolf optimizer,” Advances in Engineering Software, vol. 69, pp. 46–61, 2014. DOI: https://doi.org/10.1016/j.advengsoft.2013.12.007.

[12] B. Tu, F. Wang, Y. Huo, and X. Wang, “A hybrid algorithm of grey wolf optimizer and Harris hawks optimization for solving global optimization problems with improved convergence performance,” Scientific Reports, vol. 13, p. 22909, 2023. DOI: https://doi.org/10.1038/s41598-023-49754-2.

[13] M. Yu, J. Xu, W. Liang, Y. Qiu, S. Bao, and L. Tang, “Improved multi-strategy adaptive grey wolf optimization for practical engineering applications and high-dimensional problem solving,” Artificial Intelligence Review, vol. 57, p. 277, 2024. DOI: https://doi.org/10.1007/s10462-024-10821-3.

[14] Y. S. Ali, S. M. Searan, R. H. Qasim, and S. A. Aliesawi, “Hyperparameter optimization for CNN, K-NN, and decision tree in handwritten digit classification,” Ingénierie des Systèmes d’Information, vol. 30, no. 5, pp. 1201–1207, 2025. DOI: https://doi.org/10.18280/isi.300508.

[15] D. Trianda, D. Hartama, and S. Solikhun, “Comparison of hyperparameter tuning methods for optimizing K-nearest neighbor performance in predicting hypertension risk,” JURNAL TEKNIK INFORMATIKA, vol. 18, no. 1, pp. 111–121, 2025. DOI: https://doi.org/10.15408/jti.v18i1.42260.

[16] J. Joseph and K. Kartheeban, “Visualizing the full spectrum optimization of K-nearest neighbors from data preprocessing to hyperparameter tuning and K-fold validation for cardiovascular disease prediction,” Informatica, vol. 49, no. 2, 2025. DOI: https://doi.org/10.31449/inf.v49i2.7774.

[17] R. Seyghaly, J. Garcia, X. Masip-Bruin, and J. Kuljanin, “SBNNR: Small-size bat-optimized KNN regression,” Future Internet, vol. 16, no. 11, p. 422, 2024. DOI: https://doi.org/10.3390/fi16110422.

[18] J. M. Tan, H. Liao, W. Liu, C. Fan, J. Huang, Z. Liu, and J. Yan, “Hyperparameter optimization: Classics, acceleration, online, multi-objective, and tools,” Mathematical Biosciences and Engineering, vol. 21, no. 6, pp. 6289–6335, 2024. DOI: https://doi.org/10.3934/mbe.2024275.

[19] scikit-learn developers, “KNeighborsClassifier — scikit-learn documentation,” 2026. URL: https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html. Accessed: 30 Apr. 2026.

[20] T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning: Data Mining, Inference, and Prediction, 2nd ed. Springer, 2009. DOI: https://doi.org/10.1007/978-0-387-84858-7. URL: https://link.springer.com/book/10.1007/978-0-387-84858-7. Accessed: 30 Apr. 2026.

[21] MathWorks, “bayesopt — Select optimal machine learning hyperparameters using Bayesian optimization,” documentation. URL: https://www.mathworks.com/help/stats/bayesopt.html. Accessed: 29 Apr. 2026.

[22] Y. Rimal, N. Sharma, and A. Alsadoon, “The accuracy of machine learning models relies on hyperparameter tuning: Student result classification using random forest, randomized search, grid search, Bayesian, genetic, and Optuna algorithms,” Multimedia Tools and Applications, vol. 83, pp. 74349–74364, 2024. DOI: https://doi.org/10.1007/s11042-024-18426-2.

[23] MathWorks, “Surrogate optimization algorithm,” documentation. URL: https://www.mathworks.com/help/gads/surrogate-optimization-algorithm.html. Accessed: 29 Apr. 2026.

[24] MathWorks, “surrogateopt — Surrogate optimization for global minimization,” documentation. URL: https://www.mathworks.com/help/gads/surrogateopt.html. Accessed: 29 Apr. 2026.

[25] J. Yao, X. Luo, F. Li, J. Li, J. Dou, and H. Luo, “Research on hybrid strategy particle swarm optimization algorithm and its applications,” Scientific Reports, vol. 14, p. 24928, 2024. DOI: https://doi.org/10.1038/s41598-024-76010-y.

[26] M. Yu, J. Xu, W. Liang, Y. Qiu, S. Bao, and L. Tang, “Improved multi-strategy adaptive grey wolf optimization for practical engineering applications and high-dimensional problem solving,” Artificial Intelligence Review, vol. 57, p. 277, 2024. DOI: https://doi.org/10.1007/s10462-024-10821-3.

[27] UCI Machine Learning Repository, Heart Disease, dataset. University of California, Irvine, 1988. URL: https://archive.ics.uci.edu/ml/datasets/heart%20disease. Accessed: 30 Apr. 2026.

[28] UCI Machine Learning Repository, Ionosphere, dataset. University of California, Irvine, 1988. URL: https://archive.ics.uci.edu/ml/datasets/Ionosphere. Accessed: 30 Apr. 2026.

[29] UCI Machine Learning Repository, Spambase, dataset. University of California, Irvine, 1999. URL: https://archive.ics.uci.edu/ml/datasets/Spambase. Accessed: 30 Apr. 2026.

[30] UCI Machine Learning Repository, Haberman’s Survival, dataset. University of California, Irvine, 1999. URL: https://archive.ics.uci.edu/dataset/43/haberman+s+survival. Accessed: 30 Apr. 2026.

[31] OpenML, blood-transfusion-service-center, OpenML Dataset 1464. OpenML, 2015. URL: https://www.openml.org/d/1464. Accessed: 30 Apr. 2026.

[32] UCI Machine Learning Repository, Connectionist Bench (Sonar, Mines vs. Rocks), dataset. University of California, Irvine, 1988. URL: https://archive.ics.uci.edu/ml/datasets/Connectionist+Bench+%28Sonar%2C+Mines+vs.+Rocks%29. Accessed: 30 Apr. 2026.

[33] UCI Machine Learning Repository, Breast Cancer (Ljubljana), dataset. University of California, Irvine, 1988. URL: https://archive.ics.uci.edu/dataset/14/breast+cancer. Accessed: 30 Apr. 2026.

[34] mlbench package authors, “mlbench: Machine learning benchmark problems — PimaIndiansDiabetes,” 2026. URL: https://search.r-project.org/CRAN/refmans/mlbench/html/PimaIndiansDiabetes.html. Accessed: 30 Apr. 2026.

[35] UCI Machine Learning Repository, Iris, dataset. University of California, Irvine, 1988. URL: https://archive.ics.uci.edu/ml/datasets/Iris. Accessed: 30 Apr. 2026.

[36] UCI Machine Learning Repository, Wine, dataset. University of California, Irvine, 1991. URL: https://archive.ics.uci.edu/ml/datasets/wine. Accessed: 30 Apr. 2026.

[37] UCI Machine Learning Repository, Statlog (Landsat Satellite), dataset. University of California, Irvine, 1993. URL: https://archive.ics.uci.edu/dataset/146/statlog+landsat+satellite. Accessed: 30 Apr. 2026.

[38] UCI Machine Learning Repository, Glass Identification, dataset. University of California, Irvine, 1987. URL: https://archive.ics.uci.edu/ml/datasets/Glass+Identification. Accessed: 30 Apr. 2026.

[39] UCI Machine Learning Repository, Wine Quality, dataset. University of California, Irvine, 2009. URL: https://archive.ics.uci.edu/dataset/186/wine+quality. Accessed: 30 Apr. 2026.

[40] UCI Machine Learning Repository, Yeast, dataset. University of California, Irvine, 1996. URL: https://archive.ics.uci.edu/ml/datasets/Yeast. Accessed: 30 Apr. 2026.

[41] J. Demšar, “Statistical comparisons of classifiers over multiple data sets,” Journal of Machine Learning Research, vol. 7, no. 1, pp. 1–30, 2006. URL: https://jmlr.org/papers/volume7/demsar06a/demsar06a.pdf.

[42] S. Holm, “A simple sequentially rejective multiple test procedure,” Scandinavian Journal of Statistics, vol. 6, no. 2, pp. 65–70, 1979. URL: https://www.jstor.org/stable/4615733.

[43] P. D. Kusuma and M. Kallista, “Stochastic Komodo algorithm,” International Journal of Intelligent Engineering & Systems, vol. 15, no. 4, 2022.

[44] P. D. Kusuma and M. Kallista, “Swarm space hopping algorithm: A swarm-based stochastic optimizer enriched with half space hopping search,” International Journal of Intelligent Engineering & Systems, vol. 17, no. 2, 2024.

[45] P. D. Kusuma and M. Kallista, “Migration-crossover algorithm: A swarm-based metaheuristic enriched with crossover technique and unbalanced neighbourhood search,” International Journal of Intelligent Engineering & Systems, vol. 17, no. 1, 2024.




DOI: https://doi.org/10.18860/cauchy.v11i2.42295

Refbacks

  • There are currently no refbacks.


Copyright (c) 2026 Meta Kallista, Ig. Prasetya Dwi Wibawa, Heni Widayani

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

Editorial Office
Mathematics Department,
Maulana Malik Ibrahim State Islamic University of Malang
Gajayana Street 50 Malang, East Java, Indonesia 65144
e-mail: cauchy@uin-malang.ac.id

Creative Commons License
CAUCHY: Jurnal Matematika Murni dan Aplikasi is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.