Comparison of K-Nearest Neighbors and Naive Bayes Classifier Algorithms in Sentiment Analysis of 2024 Election in Twitter (X)

This study compares the performance of the K-Nearest Neighbors (K-NN) and Naive Bayes Classifier (NBC) algorithms in sentiment analysis of the 2024 Regional Election (Pilkada) based on Indonesian local data sourced from platform X. A total of 1,187 tweets were collected through crawling, followed by...

Full description

Saved in:
Bibliographic Details
Main Authors: Lola Enjelia, Yana Cahyana, Rahmat, Deden Wahiddin
Format: Article
Language:English
Published: Politeknik Negeri Batam 2025-06-01
Series:Journal of Applied Informatics and Computing
Subjects:
Online Access:https://jurnal.polibatam.ac.id/index.php/JAIC/article/view/9593
Tags: Add Tag
No Tags, Be the first to tag this record!
Description
Summary:This study compares the performance of the K-Nearest Neighbors (K-NN) and Naive Bayes Classifier (NBC) algorithms in sentiment analysis of the 2024 Regional Election (Pilkada) based on Indonesian local data sourced from platform X. A total of 1,187 tweets were collected through crawling, followed by extensive preprocessing and manual sentiment labeling by a professional linguist to ensure data validity and reliability. The study highlights NBC's superior accuracy (81.05%) compared to K-NN (75.26%), largely due to the characteristics of short-text social media data that align with NBC's independence assumptions. Key terms identified through TF-IDF analysis include “pilkada”, “2024”, and “damai” in positive sentiment, while “mahkamah konstitusi” and “kalah” dominated negative sentiment. The results imply that although public discourse largely supports the election process, critical sentiments toward election dispute issues persist. These findings offer practical implications for election authorities, policymakers, and digital campaign strategists, particularly in optimizing public communication strategies, early detection of potential conflicts, and designing public opinion monitoring systems based on real-time sentiment analysis. By leveraging high-quality labeled local data, this study makes a significant contribution to modeling public opinion dynamics in Indonesia during political events.
ISSN:2548-6861