Emotion Detection on Platform X Comment with Naive Bayes Classification

Authors

DOI:

https://doi.org/10.25139/ijair.v7i2.11156

Keywords:

Emotion Detection, Naive Bayes Classifier, TF-IDF, X-platform, Natural language processing

Abstract

This study aims to develop an effective emotion-detection model for Indonesian-language Twitter comments using a lightweight, interpretable machine learning approach. The proposed method combines the Naive Bayes Classifier (NBC) with Term Frequency–Inverse Document Frequency (TF–IDF) for text feature extraction. The dataset used in this study comprises 3,115 Indonesian-language comments from the publicly available X Emotion Dataset. Emotion detection on Platform X is essential given the platform's high activity and the need for automated monitoring of public sentiment and online behaviour. Four data split scenarios, among them 60:40, 70:30, 80:20, and 90:10, were evaluated to measure the model's accuracy, recall, and precision in classifying emotions into anger, happiness, and sadness. The experimental results show that the 80:20 ratio achieved the highest accuracy of 68.86%, providing an optimal balance between learning efficiency and generalization capability. The anger class consistently achieved the highest recognition rate, while the happy and sad classes showed moderate results due to overlapping linguistic characteristics. Although this study is limited to three emotion classes and a single algorithm, the findings demonstrate that the Naive Bayes–TF–IDF combination remains robust for emotion classification in resource-limited languages. This research contributes an interpretable, computationally efficient framework for social media sentiment analysis and digital behavioural studies in the Indonesian language context.

References

E. Ford, S. Shepherd, K. Jones, and L. Hassan, "Toward an ethical framework for the text mining of social media for health research: a systematic review," Frontiers in Digital Health, vol. 2, pp. 1–19, 2021, doi: 10.3389/fdgth.2020.592237.

DataReportal, “Digital 2023: Indonesia.” 2023. [Online]. Available: https://datareportal.com/reports/digital-2023-indonesia

K. Arifin and S. I. Al-Idrus, “Klasifikasi emosi pengguna twitter terhadap bakal calon presiden pada pemilu 2024 menggunakan algoritma naïve bayes,” Jurnal SAINTIKOM (Jurnal Sains Manajemen Informatika dan Komputer), vol. 23, no. 1, p. 37, 2024, doi: 10.53513/jis.v23i1.9558.

A. Pratama and L. Findawati, "Analysis of hate speech on Platform X in Indonesian online discourse," Journal of Social Media and Communication Studies, vol. 5, no. 1, pp. 45–54, 2024.

P. Ekman, "Basic emotions," in Handbook of cognition and emotion, T. Dalgleish and M. Power, Eds., John Wiley & Sons, 1999.

P. Nandwani and R. Verma, "A review on sentiment analysis and emotion detection from text," Social Network Analysis and Mining, vol. 11, no. 1, pp. 1–19, 2021, doi: 10.1007/s13278-021-00776-6.

A. S. Aribowo and S. Khomsah, "Implementation of text mining for emotion detection using the lexicon method (case study: Tweets about covid-19)," Telematika, vol. 18, no. 1, p. 49, 2021, doi: 10.31315/telematika.v18i1.4341.

K. Machová, M. Szabóova, J. Paralič, and J. Mičko, "Detection of emotion by text analysis using machine learning," Frontiers in Psychology, vol. 14, p. 1190326, 2023, doi: 10.3389/fpsyg.2023.1190326.

M. Z. Anbari and B. Sugiantoro, “Studi komparasi metode analisis sentimen naïve bayes, SVM, dan logistic regression pada piala dunia 2022,” Mikrotik: Jurnal Ilmiah Informatika, vol. 7, no. April, pp. 688–695, 2023, doi: 10.30865/mib.v7i2.5383.

R. Krishnan and M. Elayidom, "Emotion detection using Naive Bayes classifier," Procedia Computer Science, vol. 115, pp. 372–379, 2017, doi: 10.1016/j.procs.2017.09.123.

A. Khalil, "Comparison of SVM and naive bayes algorithms for emotion detection," International Journal of Artificial Intelligence Research, vol. 3, no. 2, pp. 78–85, 2022.

S. Azmin, "Emotion detection from bangla text corpus using naive bayes classifier," in 2019 4th international conference on electrical information and communication technology (EICT), 2019, pp. 1–5. doi: 10.1109/EICT48899.2019.9068797.

R. Sankar, P. Sharma, and V. Kumar, "Sentiment analysis on Twitter data for depression detection," Journal of Machine Learning Applications, vol. 9, no. 1, pp. 33–42, 2024.

M. Anbari and B. Sugiantoro, "Improving text classification performance using TF-IDF weighting method," Journal of Information Systems and Technology, vol. 11, no. 2, pp. 65–72, 2023.

P. Widyantara, A. Wibawa, and C. Pramartha, “Analisis sentimen pada teks berbahasa bali menggunakan metode multinomial naive bayes dengan TF-IDF dan BoW,” Journal of Language Technology and Computing, vol. 2, no. November, pp. 37–46, 2023.

R. Mazya, Suryani, and R. Pratama, "Comparative study of feature extraction using TF-IDF and Bag of Words," International Journal of Data Science and Technology, vol. 8, no. 4, pp. 121–128, 2022.

J. A. Septian, T. M. Fachrudin, and A. Nugroho, “Analisis sentimen pengguna twitter terhadap polemik persepakbolaan indonesia menggunakan pembobotan TF-IDF dan k-nearest neighbor,” Journal of Intelligent System and Computation, vol. 1, no. 1, pp. 43–49, 2019, doi: 10.52985/insyst.v1i1.36.

S. Mazya, P. Tyas, B. S. Rintyarna, and W. Suharso, "The impact of feature extraction to naïve bayes based sentiment analysis on review dataset of indihome services," Journal of Informatics and Computational Science, pp. 1–10, 2022.

T. Ridwansyah, “Implementasi text mining terhadap analisis sentimen masyarakat dunia di twitter terhadap kota medan menggunakan k-fold cross validation dan naïve bayes classifier,” Jurnal Teknologi dan Sains Komputer, vol. 2, no. 5, pp. 178–185, 2022.

A. Sudrajat, “Penerapan metode naïve bayes untuk menentukan penilaian kinerja karyawan PT. Sinergi guna solusindo,” Jurnal Teknologi dan Sains Komputer, vol. 99, no. 99, pp. 1596–1606, 2022.

C. H. Pratama and Y. Findawati, “Klasifikasi hate speech dan emosi dalam teks berbahasa indonesia pada pengguna twitter menggunakan metode naïve bayes classifier,” Indonesian Journal of Applied Technology, vol. 1, no. 3, p. 10, 2024, doi: 10.47134/ijat.v1i3.3105.

M. Muntean and F.-D. Militaru, "Metrics for evaluating classification algorithms," in Education, research and business technologies, C. Ciurea, P. Pocatilu, and F. G. Filip, Eds., Springer Nature Singapore, 2023, pp. 307–317.

G. Naidu, T. Zuva, and E. M. Sibanda, "A review of evaluation metrics in machine learning algorithms," in Artificial intelligence application in networks and systems, R. Silhavy and P. Silhavy, Eds., Springer International Publishing, 2023, pp. 15–25.

A. S. Aribowo and N. Khomsah, "Emotion analysis in Indonesian social media comments using EmoLex lexicon," Indonesian Journal of Computational Linguistics, vol. 6, no. 2, pp. 112–120, 2021.

F. Khalil Aljwari, "Emotion detection in arabic text using machine learning methods," International Journal of Information System and Computer Science (IJISCS), vol. 6, no. 5, pp. 175–185, 2022.

Downloads

Published

2025-12-05

How to Cite

Emotion Detection on Platform X Comment with Naive Bayes Classification. (2025). International Journal of Artificial Intelligence & Robotics (IJAIR), 7(2), 83–91. https://doi.org/10.25139/ijair.v7i2.11156

Most read articles by the same author(s)

Obs.: This plugin requires at least one statistics/report plugin to be enabled. If your statistics plugins provide more than one metric then please also select a main metric on the admin's site settings page and/or on the journal manager's settings pages.