Sentiment Analysis of Diabetes in X Platform Using the K-Nearest Neighbor (KNN) and Support Vector Machine (SVM) Methods: Case Study of Indonesia
摘要
Diabetes constitutes an escalating public health issue, with Indonesia positioned sixth worldwide in prevalence, recording 19.5 million cases in 2021. Comprehending public perception around diabetes on social media can guide health communication tactics and policy formulation. This study evaluates two machine learning algorithms—Support Vector Machine (SVM) and K-Nearest Neighbors (KNN)—for the classification of diabetes-related emotions on X (previously Twitter). We gathered 12,847 Indonesian tweets regarding diabetes from January to March 2024 and utilized the CRISP-DM framework for methodical data processing. Following preprocessing (cleaning, normalization, tokenization, stopword elimination, and stemming), we employed TF-IDF vectorization and lexicon-based sentiment classification. The dataset was divided in a 70:30 ratio for training and testing purposes. SVM substantially surpassed KNN, attaining an accuracy of 81.96% in contrast to 70.54%. The SVM model exhibited superior precision (83%), recall (82%), and F1-score (82%) across all emotion categories. These findings indicate that SVM is better appropriate for diabetes sentiment analysis on social media, with practical implications for public health monitoring and intervention efforts in Indonesia.