Sentiment Analysis on the Relocation of the National Capital (IKN) on Social Media X Using Naive Bayes and K-Nearest Neighbor (KNN) Methods - Wulandari, Nova; Cahyana, Yana; Rahmat, Rahmat; Hikmayanti, Hanny (Politeknik Negeri Batam, 2025)
This study investigates public sentiment toward the relocation of Indonesia’s capital from Jakarta to East Kalimantan, focusing on reactions from social media platforms such as X (formerly Twitter). Understanding these sentiments is crucial for the government to gauge support for this significant policy shift. The study compares the performance of two classification algorithms, Naïve Bayes and K-Nearest Neighbor (K-NN), in sentiment analysis. A total of 1.277 comments were collected using the tweet-harvest library through a crawling process. The data underwent preprocessing, including cleaning, case folding, normalization, stopword removal, tokenization, and stemming. Sentiment labels were assigned through both manual and automated methods, while feature extraction was performed using the TF-IDF technique. The algorithms' performance was assessed using accuracy, precision, recall, and F1-score metrics. The results revealed that Naïve Bayes outperformed K-NN, with an accuracy of 70%, precision of 72%, recall of 70%, and an F1-score of 69%. In contrast, K-NN achieved an accuracy of 60%, precision of 62%, recall of 60%, and an F1-score of 59%. These results suggest that Naïve Bayes is more effective in classifying sentiment related to the capital relocation. The findings offer valuable insights for policymakers and highlight the potential of automated sentiment analysis as a tool for monitoring public opinion on major governmental policies.