Heart failure is included in the category of cardiovascular disease. Heart disease is not easy to detect, and its detection needs to be done by experienced and skilled medical professionals. Most patients with heart failure require hospitalization. Common symptoms of heart disease, such as chest pain and high or low blood pressure, vary from person to person. This study aims to find the most optimal k value based on the accuracy obtained based on calculations by testing different k values, namely 1, 3, 5, 7, and 9. After getting the results of the accuracy of the five k values, compare which accuracy has the highest value, best for K-Nearest Neighbor (K-NN) models. The classification process uses the K-NN algorithm. This algorithm is quite easy to use because some parameters work using distance metrics and k values. Therefore, the value of k in the K-NN algorithm greatly affects the accuracy that will be produced. In the results of this study, the accuracy obtained was k = 7 and k = 9, which are the most optimal results because they have the highest accuracy compared to other k values, with an accuracy of 88%. The expected benefit of this research is that it can make a scientific contribution to research in the field of machine learning classification, especially in predicting heart failure