The Indonesian Journal of Computer Science
Vol. 14 No. 5 (2025): The Indonesian Journal of Computer Science

Comparative Analysis of Naïve Bayes and K-NN Methods on Social Media Boycott Issue X Case Study: McDonald’s

Azzahra, Morra Fatya Gisna Nourielda (Unknown)
Vitianingsih, Anik Vega (Unknown)
Cahyono, Dwi (Unknown)
Maukar, Anastasia Lidya (Unknown)
Badri, Fawaidul (Unknown)



Article Info

Publish Date
23 Oct 2025

Abstract

The boycott movement against McDonald’s, triggered by its alleged support for Israel during the conflict in Gaza, has generated significant public discourse, particularly on the social media platform X (formerly Twitter). This study investigates public sentiment regarding the boycott campaign by analyzing comments and reactions to related content. A total of 1,585 tweets were collected using techniques for web scraping and underwent a comprehensive pre-processing phase, encompassing cleaning, tokenization, filtering, and stemming. Sentiment categories, namely positive, neutral, and negative, are automatically assigned using a lexicon-based technique customized for the Indonesian language. Text data was transformed into numerical form through the Term Frequency-Inverse Document Frequency (TF-IDF) technique, followed by sentiment classification using two supervised machine learning algorithms: Naïve Bayes and K-Nearest Neighbor (K-NN). Evaluation of both models was conducted using a confusion matrix and classification metrics. The results show that the dataset is highly imbalanced, with 93.5% of the tweets labelled as negative, 6.1% as neutral, and only 0.3% as positive. The K-NN model achieved better performance than Naïve Bayes (NB), with an accuracy of 93%, a precision of 31%, a recall of 33%, and an F1-score of 32%. On the other hand, the Naïve Bayes algorithm reached 39% accuracy, 33% precision, 29% recall, and an F1-score of 22%. These findings highlight the dominance of negative sentiment toward McDonald’s and demonstrate the efficacy of the K-NN algorithm in sentiment classification in unbalanced datasets. The insights from this study can inform public relations strategies and corporate reputation management in the face of socio-political controversies.

Copyrights © 2025






Journal Info

Abbrev

ijcs

Publisher

Subject

Computer Science & IT Electrical & Electronics Engineering Engineering

Description

The Indonesian Journal of Computer Science (IJCS) is a bimonthly peer-reviewed journal published by AI Society and STMIK Indonesia. IJCS editions will be published at the end of February, April, June, August, October and December. The scope of IJCS includes general computer science, information ...