Skripsi
OPTIMASI NILAI K PADA KNN MENGGUNAKAN PARTICLE SWARM OPTIMIZATION UNTUK DIAGNOSIS STROKE
Stroke is a leading cause of disability and death worldwide, making accurate early diagnosis essential to reduce long-term impacts. This study aims to implement K-Nearest Neighbors (KNN) for Stroke diagnosis Classification and to optimize the value of K using Particle Swarm Optimization (PSO). The dataset was obtained from Kaggle, consisting of 5,110 entries and 12 demographic and clinical features. The preprocessing stages included handling missing values, standardization, categorical feature encoding, and outlier adjustment using z-score, while SMOTE was applied to balance class distribution. The experimental results of KNN show the highest accuracy of 87.9% and an F1-score of 0.896 at K=1 with a 90:10 ratio, although performance decreased as the value of K increased. In contrast, optimizing the value of K with PSO allowed a more adaptive and stable parameter selection, as the algorithm explored the best configuration through a combination of population size, inertia weight, cognitive coefficient, social coefficient, and number of iterations. At the 70:30 ratio, the optimal configuration with population = 20, W = 0.1, C1 = 3, C2 = 1, and 30 iterations achieved an accuracy of 83.43% and an F1-score of 0.857. The integration of KNN and PSO not only improved accuracy but also produced a more consistent model across different data distribution ratios. Therefore, this study demonstrates that the combination of KNN and PSO has the potential to be an effective solution for supporting Stroke diagnosis based on medical data, and it can be further developed in disease prediction systems using machine learning.