Optimization of the K-Nearest Neighbors (KNN) Algorithm in Imbalanced Dataset Classification Using the SMOTE Technique - Abi Fajar Ahmad Fauzi; Ahmad Faqih; Kaslani (Yayasan Kita Menulis, 2025)
The naturalization of players for Indonesia's national football team has sparked diverse reactions on Twitter, ranging from support to opposition. This situation poses challenges for sentiment analysis, particularly in interpreting public opinion on the policy. A significant challenge arises from the imbalance in sentiment classes, with neutral sentiments outweighing positive and negative ones. This research investigates the effect of class imbalance on sentiment analysis accuracy by employing the KNN algorithm enhanced with the SMOTE technique. A quantitative approach is used, adopting an experimental method aligned with the KDD process stages. The findings reveal that the KNN algorithm without SMOTE achieved an accuracy of 54.77%, with a Precision of 0.65, Recall of 0.57, and F1-Score of 0.44. However, integrating SMOTE with the KNN algorithm significantly improved the outcomes, boosting accuracy to 81.49%, with a Precision of 0.87, Recall of 0.80, and F1-Score of 0.80. These results demonstrate that oversampling techniques like SMOTE are highly effective in mitigating class imbalance and enhancing classification performance, especially for underrepresented classes. This study underscores the efficacy of SMOTE as a solution for addressing class imbalance in sentiment analysis tasks.