OPTIMIZATION OF K VALUE IN THE K-NEAREST NEIGHBOR ALGORITHM FOR FETAL HEALTH CLASSIFICATION - Wardhani, Anindya Khrisna; Sudra, Rano Indradi; Nugraha, Ega; Putri, Astrid Novita (Journal of Computer Science and Technology (JCS-TECH), 2025)
Fetal health classification is an essential step in supporting early diagnosis of fetal conditions and preventing pregnancy complications that can threaten the lives of both mother and fetus. The K-Nearest Neighbor (K-NN) algorithm is one of the commonly used methods for this classification due to its ability to recognize patterns from training data. However, the performance of K-NN is greatly influenced by the choice of the K value, which is the number of nearest neighbors considered in determining the class of new data. This study aims to optimize the K value in the K-NN algorithm to achieve the highest accuracy in fetal health classification. The data used consists of cardiotocography (CTG) examination results classified into three categories is Normal, Suspect, and Pathological. K values from 1 to 20 were tested to determine the optimal K value based on classification accuracy. The results indicate that the optimal K range is between 1 and 3, with the highest accuracy achieved at K = 1 and K = 2, both at 99.91%. In contrast, K values greater than 3 show a significant decrease in accuracy. Based on these findings, K = 3 is chosen as the optimal value to balance high accuracy with the model’s generalization capability. In conclusion, optimizing the K value in the K-NN algorithm can improve the accuracy of fetal health classification, potentially supporting more accurate and timely medical decision-making. These findings can be applied in developing a more reliable fetal health prediction system, thereby contributing to reducing the risk of maternal and fetal health complications