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

Authors

  • Morra Fatya Gisna Nourielda Azzahra Informatics Departemen, Universitas Dr.Soetomo, Surabaya
  • Anik Vega Vitianingsih Informatics Department, Universitas Dr. Soetomo
  • Dwi Cahyono Informatics Departemen, Universitas Dr.Soetomo, Surabaya
  • Anastasia Lidya Maukar Industrial Engineering Department, President University, Bekasi
  • Fawaidul Badri Informatics Department, Universitas Islam Malang

DOI:

https://doi.org/10.33022/ijcs.v14i5.4956

Keywords:

Natural Language Processing, Machine Learning, Sentiment Analysis, McDonald’s Boycott, Pro-Israel Boycott, Naïve Bayes, KNN

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.

Downloads

Published

23-10-2025