Building of Informatics, Technology and Science
Vol 7 No 2 (2025): September 2025

Implementasi Grid Search CV KNN dengan Preprocessing Z-Score Outlier Removal untuk Sistem Prediksi Risiko Kehamilan

Anggita, Ivan Maulana (Unknown)
Naufal, Muhammad (Unknown)
Zami, Farrikh Al (Unknown)



Article Info

Publish Date
04 Sep 2025

Abstract

This study aims to optimize the K-Nearest Neighbors (KNN) algorithm in predicting pregnancy risk levels using the “maternal health risk” dataset from the UCI Machine Learning Repository. The methodology includes data preprocessing through outlier detection and removal using Z-score, normalization with Standard Scaling, and categorical encoding on the target labels. Hyperparameter tuning is performed using GridSearchCV to identify the optimal combination of KNN parameters (number of neighbors, distance weight, and distance metric). The results show that the unoptimized KNN model achieved an accuracy of only 69.46%, whereas the optimized model reached an accuracy of 82.00%, with macro average precision of 81.91%, recall of 82.89%, and F1-score of 82.23%. Evaluation using a confusion matrix also revealed significant performance improvement, especially in the high-risk category. The optimized model was deployed as a web application using the Flask framework and Docker via Hugging Face Spaces, enabling real-time and efficient online pregnancy prediction. These findings indicate that combining KNN with GridSearchCV and data normalization significantly enhances prediction performance and offers practical application in healthcare decision support systems.

Copyrights © 2025






Journal Info

Abbrev

bits

Publisher

Subject

Computer Science & IT

Description

Building of Informatics, Technology and Science (BITS) is an open access media in publishing scientific articles that contain the results of research in information technology and computers. Paper that enters this journal will be checked for plagiarism and peer-rewiew first to maintain its quality. ...