Machine Learning Approach for Heart Failure Patient Classification Using K-Nearest Neighbors Algorithm - Masitha, Alya; Lonang, Syahrani; Reski, Julia Mega (PT. Teknologi Futuristik Indonesia, 2025)
Heart failure is a cardiovascular disease with a high mortality rate and tends to increase every year. Therefore, a method is needed that can help the process of classifying heart failure quickly and accurately. This study aims to design and implement a heart failure classification system using the K-Nearest Neighbor (K-NN) machine learning method. The dataset used consists of 918 patient data with eleven input variables and two output classes, namely patients diagnosed with heart failure and patients not diagnosed with heart failure. The research stages include data loading, dividing training data and test data, implementing the K-NN algorithm with various K values, and evaluating model performance using accuracy, precision, recall, and F1-score metrics. The test results show that variations in the K value have a significant effect on the performance of the classification model. The K value = 9 produces the best performance with an accuracy of 93.48%, a recall of 96.36%, and an F1-score of 94.64%, which indicates a good balance between precision and recall. Based on these results, the K-NN method with a value of K = 9 is recommended as the optimal configuration in the classification of heart failure disease in this study.