Emotion Detection in Indonesian Text Using the Logistic Regression Method
DOI:
https://doi.org/10.35194/mji.v17i2.5927Keywords:
Emotion Detection, Logistic Regression, Ensemble Bagging, Text Mining, Data TextAbstract
Emotion detection in Indonesian text has become a crucial topic in the advancement of human–computer interaction and sentiment analysis on digital platforms. Despite its importance, challenges arise from the linguistic complexity and frequent use of slang in Indonesian text. This study aims to evaluate the performance of three classification models—Logistic Regression, K-Nearest Neighbors (KNN), and Naive Bayes—in detecting emotions from Indonesian text. The dataset comprises 1,000 texts categorized into four emotions: happy, sad, angry, and fear. Preprocessing steps included slang normalization, text cleaning, tokenization, stopword removal, and stemming, followed by TF-IDF weighting. Each model was trained and further optimized using ensemble bagging to improve classification performance. The optimized Logistic Regression model achieved the best performance, with an accuracy of 89%, precision of 0.90, recall of 0.89, F1-score of 0.89, and an average ROC-AUC score of 0.98. Both KNN and Naive Bayes models reached 81% accuracy after optimization, but their overall performance remained lower than Logistic Regression. The findings demonstrate that Logistic Regression is the most effective method for detecting emotions in Indonesian text, as it can effectively handle simple grammatical structures and slang variations. This study contributes to the development of emotion analysis models for Indonesian text, supporting applications in social computing and affective computing.References
[1] A. N. Rohman, E. Utami, and S. Raharjo, “Deteksi Kondisi Emosi pada Media Sosial Menggunakan Pendekatan Leksikon dan Natural Language Processing,” Eksplora Inform., vol. 9, no. 1, pp. 70–76, Sep. 2019.
[2] J. Bata, Suyoto, and Pranowo, “Leksikon untuk Deteksi dari Teks Bahsa Indonesia,” 2018.
[3] R. Sutoyo, H. L. H. S. Warnars, S. M. Isa, and W. Budiharto, “Indonesian Twitter Emotion Recognition Model using Feature Engineering,” Int. J. Adv. Comput. Sci. Appl., vol. 14, no. 12, pp. 1057–1065, 2023.
[4] F. M. Alotaibi, “Classifying Text-Based Emotions Using Logistic Regression,” VAWKUM Trans. Comput. Sci., vol. 7, no. 1, pp. 31–37, Apr. 2019.
[5] D. A. Nur’Faradila, L. Magdalena, and M. Febima, “Penerapan Naïve Bayes Classifier Untuk Klasifikasi Postingan Berita Hoaks Di Instagram Cirebon Saber Hoaks,” Media J. Inform., vol. 16, no. 2, p. 243, Dec. 2024.
[6] M. D. R. Wahyudi, “Penerapan Algoritma Cosine Similarity pada Text Mining Terjemah Al-Qur’an Berdasarkan Keterkaitan Topik,” Semesta Tek., vol. 22, no. 1, 2019.
[7] F. Rahutomo, A. Retno, and T. H. Ririd, “Evaluasi Daftar Stopword Bahasa Indonesia,” J. Teknol. Inf. dan Ilmu Komput., vol. 6, no. 1, pp. 41–48, Jan. 2019.
[8] E. Junianto and R. Rachman, “Penerapan Metode Naïve Bayes Classifier Untuk Mendeteksi Emosi Pada Komentar Media Sosial,” J. Responsif Ris. Sains dan Inform., vol. 2, no. 1, pp. 1–8, Feb. 2020.
[9] F. Fanesya, R. C. Wihandika, and I. Indriati, “Deteksi Emosi Pada Twitter Menggunakan Metode Naive Bayes Dan Kombinasi Fitur,” J. Pengemb. Teknol. Inf. dan Ilmu Komput., vol. 3, no. 7, pp. 6678–6686, Aug. 2019.
[10] APJII, “Asosiasi Penyelenggara Jasa Internet Indonesia - Survei,” 2024. [Online]. Available: https://survei.apjii.or.id/survei. [Accessed: 13-Apr-2025].
[11] A. Kurniasih, A. K. Santoso, B. D. Wicaksono, and H. F. Pardede, “Evaluations of Emotion Analysis of Tweets using Bidirectional Long Short Term Memory and Conventional Machine Learning,” J. Teknol. dan Sist. Komput., vol. 10, no. 2, Apr. 2022.
[12] A. Glenn, P. LaCasse, and B. Cox, “Emotion classification of Indonesian Tweets using Bidirectional LSTM,” Neural Comput. Appl., vol. 35, no. 13, pp. 9567–9578, May 2023.
[13] R. N. Sofia and D. Supriyadi, “Komparasi Metode Machine Learning dan Deep Learning untuk Deteksi Emosi pada Text di Sosial Media,” JUPITER J. Penelit. Ilmu dan Teknol. Komput., vol. 13, no. 2, pp. 130–139, Oct. 2021.
[14] A. B. P. Negara, H. Muhardi, and F. Sajid, “Perbandingan Algoritma Klasifikasi terhadap Emosi Tweet Berbahasa Indonesia,” J. Edukasi dan Penelit. Inform., vol. 7, no. 2, p. 242, Aug. 2021.
[15] M. Cindo, D. P. Rini, and E. Ermatita, “Literatur Review: Metode Klasifikasi Pada Sentimen Analisis,” Semin. Nas. Teknol. Komput. Sains, vol. 1, no. 1, pp. 66–70, Feb. 2019.
[16] O. Ndama, I. Bensassi, and E. M. En-Naimi, “The impact of BERT-infused deep learning models on sentiment analysis accuracy in financial news,” Bull. Electr. Eng. Informatics, vol. 14, no. 2, pp. 1231–1240, Apr. 2025.
[17] A. R. Abas, I. Elhenawy, M. Zidan, and M. Othman, “BERT-CNN: A Deep Learning Model for Detecting Emotions from Text,” Comput. Mater. Contin., vol. 71, no. 2, pp. 2943–2961, 2022.
[18] K. Machová, M. Szabóova, J. Parali?, and J. Mi?ko, “Detection of emotion by text analysis using machine learning,” Front. Psychol., vol. 14, 2023.
[19] R. Afrinanda, … L. E.-M. J., and undefined 2023, “Hybrid Model for Sentiment Analysis of Bitcoin Prices using Deep Learning Algorithm,” journal.universitasbumigora.ac.id.
[20] Nanira Annisa Fitri, Taufik Edy Sutanto, and Muhaza Liebenlito, “Deteksi Kepribadian MBTI pada Diskusi Agama Islam di Twitter Indonesia 2009-2019,” Indones. J. Comput. Sci., vol. 12, no. 5, Oct. 2023.
[21] E. Junianto, M. Puspitasari, S. I. Zakaria, T. Arifin, I. Wiseto, and P. Agung, “Klasifikasi Emosi pada Teks Berbahasa Inggris Menggunakan Pendekatan Ensemble Bagging,” J. Nas. Tek. Elektro dan Teknol. Inf., vol. 13, no. 4, pp. 272–281, Nov. 2024.
[22] A. H. L. Noer and Dedi Wijayanti, “Directive Acts of Speech in Kajian Malam Ahad Kanal Dr. Zaidul Akbar and its Relation to Teaching Materials for Persuasive Texts in Class VIII Junior High Schools,” Aksis J. Pendidik. Bhs. dan Sastra Indones., vol. 8, no. 1, pp. 33–47, Jun. 2024.
[23] W. A. Setyati, S. Sunaryo, A. Rezagama, A. K. Widodo, and M. F. A. Yulianto, “Penerapan Regresi Logistik Dalam Penentuan Faktor Yang Mempengaruhi Jumlah Wisatawan Ecotourism Desa Bedono,” J. ENGGANO, vol. 5, no. 1, pp. 11–22, Apr. 2020.
[24] W. O. Simanjuntak, A. Bijaksana, P. Negara, and R. Septriana, “Perbandingan Algoritma Logistic Regression dan Random Foret (Studi Kasus?: Klasifikasi Emosi Tweet),” J. Apl. dan Ris. Inform., vol. 1, no. 2, pp. 160–164, Jun. 2023.
[25] F. Sukmanisa, Y. A. Sari, and I. Cholissodin, “Deteksi Emosi pada Tweet Berbahasa Indonesia tentang Pembelajaran Jarak Jauh Menggunakan K-Nearest Neighbor dengan Pembobotan Kata Term Frequency-Inverse Gravity Moment,” J. Pengemb. Teknol. Inf. dan Ilmu Komput., vol. 5, no. 9, pp. 4033–4041, Sep. 2021.
[26] D. R. Wulandari, C. Setianingsih, and F. M. Dirgantara, “Deteksi Emosi Berbasis Teks Untuk Menganalisis Kuliah Daring Selama Masa Pandemi Menggunakan Algoritme Naive Bayes,” eProceedings Eng., vol. 9, no. 4, Aug. 2022.
[27] F. H. Rachman and I. Imamah, “Pendekatan Data Science untuk Mengukur Empati Masyarakat terhadap Pandemi Menggunakan Analisis Sentimen dan Seleksi Fitur,” J. Edukasi dan Penelit. Inform., vol. 8, no. 3, p. 492, Dec. 2022.
[28] L. Annisa and A. D. Kalifia, “Analisis Teknik TF-IDF Dalam Identifikasi Faktor-Faktor Penyebab Depresi Pada Individu,” Gudang J. Multidisiplin Ilmu, vol. 2, no. 1, pp. 302–307, Jan. 2024.
[29] W. Widayat, “Analisis Sentimen Movie Review menggunakan Word2Vec dan metode LSTM Deep Learning,” J. MEDIA Inform. BUDIDARMA, vol. 5, no. 3, p. 1018, Jul. 2021.
[30] D. Onita, “Active Learning Based on Transfer Learning Techniques for Text Classification,” IEEE Access, vol. 11, pp. 28751–28761, 2023.
[31] F. Rustam, A. Mehmood, M. Ahmad, S. Ullah, D. M. Khan, and G. S. Choi, “Classification of Shopify App User Reviews Using Novel Multi Text Features,” IEEE Access, vol. 8, pp. 30234–30244, 2020.
[32] N. Ramadhani and N. Fajarianto, “Sistem Informasi Evaluasi Perkuliahan dengan Sentimen Analisis Menggunakan Naïve Bayes dan Smoothing Laplace,” J. Sist. Inf. BISNIS, vol. 10, no. 2, pp. 228–234, Dec. 2020.
[33] D. Kurniawan, H. D. Purnomo, and A. Iriani, “Analisis Sentimen Komentar Konsumen Industri Jamu di Media Sosial menggunakan Artificial Neural Network dan K-Nearest Neighbor,” J. Sist. Inf. Bisnis, vol. 14, no. 3, pp. 210–223, Aug. 2024.
[34] F. D. U. Arif, “Perbandingan kinerja algoritma random forest, xgboost dan lightgbm dalam klasifikasi emosi komentar reddit,” Fakultas Sains dan Teknologi UIN Syarif HIdayatullah Jakarta, Jakarta, 2024.
[2] J. Bata, Suyoto, and Pranowo, “Leksikon untuk Deteksi dari Teks Bahsa Indonesia,” 2018.
[3] R. Sutoyo, H. L. H. S. Warnars, S. M. Isa, and W. Budiharto, “Indonesian Twitter Emotion Recognition Model using Feature Engineering,” Int. J. Adv. Comput. Sci. Appl., vol. 14, no. 12, pp. 1057–1065, 2023.
[4] F. M. Alotaibi, “Classifying Text-Based Emotions Using Logistic Regression,” VAWKUM Trans. Comput. Sci., vol. 7, no. 1, pp. 31–37, Apr. 2019.
[5] D. A. Nur’Faradila, L. Magdalena, and M. Febima, “Penerapan Naïve Bayes Classifier Untuk Klasifikasi Postingan Berita Hoaks Di Instagram Cirebon Saber Hoaks,” Media J. Inform., vol. 16, no. 2, p. 243, Dec. 2024.
[6] M. D. R. Wahyudi, “Penerapan Algoritma Cosine Similarity pada Text Mining Terjemah Al-Qur’an Berdasarkan Keterkaitan Topik,” Semesta Tek., vol. 22, no. 1, 2019.
[7] F. Rahutomo, A. Retno, and T. H. Ririd, “Evaluasi Daftar Stopword Bahasa Indonesia,” J. Teknol. Inf. dan Ilmu Komput., vol. 6, no. 1, pp. 41–48, Jan. 2019.
[8] E. Junianto and R. Rachman, “Penerapan Metode Naïve Bayes Classifier Untuk Mendeteksi Emosi Pada Komentar Media Sosial,” J. Responsif Ris. Sains dan Inform., vol. 2, no. 1, pp. 1–8, Feb. 2020.
[9] F. Fanesya, R. C. Wihandika, and I. Indriati, “Deteksi Emosi Pada Twitter Menggunakan Metode Naive Bayes Dan Kombinasi Fitur,” J. Pengemb. Teknol. Inf. dan Ilmu Komput., vol. 3, no. 7, pp. 6678–6686, Aug. 2019.
[10] APJII, “Asosiasi Penyelenggara Jasa Internet Indonesia - Survei,” 2024. [Online]. Available: https://survei.apjii.or.id/survei. [Accessed: 13-Apr-2025].
[11] A. Kurniasih, A. K. Santoso, B. D. Wicaksono, and H. F. Pardede, “Evaluations of Emotion Analysis of Tweets using Bidirectional Long Short Term Memory and Conventional Machine Learning,” J. Teknol. dan Sist. Komput., vol. 10, no. 2, Apr. 2022.
[12] A. Glenn, P. LaCasse, and B. Cox, “Emotion classification of Indonesian Tweets using Bidirectional LSTM,” Neural Comput. Appl., vol. 35, no. 13, pp. 9567–9578, May 2023.
[13] R. N. Sofia and D. Supriyadi, “Komparasi Metode Machine Learning dan Deep Learning untuk Deteksi Emosi pada Text di Sosial Media,” JUPITER J. Penelit. Ilmu dan Teknol. Komput., vol. 13, no. 2, pp. 130–139, Oct. 2021.
[14] A. B. P. Negara, H. Muhardi, and F. Sajid, “Perbandingan Algoritma Klasifikasi terhadap Emosi Tweet Berbahasa Indonesia,” J. Edukasi dan Penelit. Inform., vol. 7, no. 2, p. 242, Aug. 2021.
[15] M. Cindo, D. P. Rini, and E. Ermatita, “Literatur Review: Metode Klasifikasi Pada Sentimen Analisis,” Semin. Nas. Teknol. Komput. Sains, vol. 1, no. 1, pp. 66–70, Feb. 2019.
[16] O. Ndama, I. Bensassi, and E. M. En-Naimi, “The impact of BERT-infused deep learning models on sentiment analysis accuracy in financial news,” Bull. Electr. Eng. Informatics, vol. 14, no. 2, pp. 1231–1240, Apr. 2025.
[17] A. R. Abas, I. Elhenawy, M. Zidan, and M. Othman, “BERT-CNN: A Deep Learning Model for Detecting Emotions from Text,” Comput. Mater. Contin., vol. 71, no. 2, pp. 2943–2961, 2022.
[18] K. Machová, M. Szabóova, J. Parali?, and J. Mi?ko, “Detection of emotion by text analysis using machine learning,” Front. Psychol., vol. 14, 2023.
[19] R. Afrinanda, … L. E.-M. J., and undefined 2023, “Hybrid Model for Sentiment Analysis of Bitcoin Prices using Deep Learning Algorithm,” journal.universitasbumigora.ac.id.
[20] Nanira Annisa Fitri, Taufik Edy Sutanto, and Muhaza Liebenlito, “Deteksi Kepribadian MBTI pada Diskusi Agama Islam di Twitter Indonesia 2009-2019,” Indones. J. Comput. Sci., vol. 12, no. 5, Oct. 2023.
[21] E. Junianto, M. Puspitasari, S. I. Zakaria, T. Arifin, I. Wiseto, and P. Agung, “Klasifikasi Emosi pada Teks Berbahasa Inggris Menggunakan Pendekatan Ensemble Bagging,” J. Nas. Tek. Elektro dan Teknol. Inf., vol. 13, no. 4, pp. 272–281, Nov. 2024.
[22] A. H. L. Noer and Dedi Wijayanti, “Directive Acts of Speech in Kajian Malam Ahad Kanal Dr. Zaidul Akbar and its Relation to Teaching Materials for Persuasive Texts in Class VIII Junior High Schools,” Aksis J. Pendidik. Bhs. dan Sastra Indones., vol. 8, no. 1, pp. 33–47, Jun. 2024.
[23] W. A. Setyati, S. Sunaryo, A. Rezagama, A. K. Widodo, and M. F. A. Yulianto, “Penerapan Regresi Logistik Dalam Penentuan Faktor Yang Mempengaruhi Jumlah Wisatawan Ecotourism Desa Bedono,” J. ENGGANO, vol. 5, no. 1, pp. 11–22, Apr. 2020.
[24] W. O. Simanjuntak, A. Bijaksana, P. Negara, and R. Septriana, “Perbandingan Algoritma Logistic Regression dan Random Foret (Studi Kasus?: Klasifikasi Emosi Tweet),” J. Apl. dan Ris. Inform., vol. 1, no. 2, pp. 160–164, Jun. 2023.
[25] F. Sukmanisa, Y. A. Sari, and I. Cholissodin, “Deteksi Emosi pada Tweet Berbahasa Indonesia tentang Pembelajaran Jarak Jauh Menggunakan K-Nearest Neighbor dengan Pembobotan Kata Term Frequency-Inverse Gravity Moment,” J. Pengemb. Teknol. Inf. dan Ilmu Komput., vol. 5, no. 9, pp. 4033–4041, Sep. 2021.
[26] D. R. Wulandari, C. Setianingsih, and F. M. Dirgantara, “Deteksi Emosi Berbasis Teks Untuk Menganalisis Kuliah Daring Selama Masa Pandemi Menggunakan Algoritme Naive Bayes,” eProceedings Eng., vol. 9, no. 4, Aug. 2022.
[27] F. H. Rachman and I. Imamah, “Pendekatan Data Science untuk Mengukur Empati Masyarakat terhadap Pandemi Menggunakan Analisis Sentimen dan Seleksi Fitur,” J. Edukasi dan Penelit. Inform., vol. 8, no. 3, p. 492, Dec. 2022.
[28] L. Annisa and A. D. Kalifia, “Analisis Teknik TF-IDF Dalam Identifikasi Faktor-Faktor Penyebab Depresi Pada Individu,” Gudang J. Multidisiplin Ilmu, vol. 2, no. 1, pp. 302–307, Jan. 2024.
[29] W. Widayat, “Analisis Sentimen Movie Review menggunakan Word2Vec dan metode LSTM Deep Learning,” J. MEDIA Inform. BUDIDARMA, vol. 5, no. 3, p. 1018, Jul. 2021.
[30] D. Onita, “Active Learning Based on Transfer Learning Techniques for Text Classification,” IEEE Access, vol. 11, pp. 28751–28761, 2023.
[31] F. Rustam, A. Mehmood, M. Ahmad, S. Ullah, D. M. Khan, and G. S. Choi, “Classification of Shopify App User Reviews Using Novel Multi Text Features,” IEEE Access, vol. 8, pp. 30234–30244, 2020.
[32] N. Ramadhani and N. Fajarianto, “Sistem Informasi Evaluasi Perkuliahan dengan Sentimen Analisis Menggunakan Naïve Bayes dan Smoothing Laplace,” J. Sist. Inf. BISNIS, vol. 10, no. 2, pp. 228–234, Dec. 2020.
[33] D. Kurniawan, H. D. Purnomo, and A. Iriani, “Analisis Sentimen Komentar Konsumen Industri Jamu di Media Sosial menggunakan Artificial Neural Network dan K-Nearest Neighbor,” J. Sist. Inf. Bisnis, vol. 14, no. 3, pp. 210–223, Aug. 2024.
[34] F. D. U. Arif, “Perbandingan kinerja algoritma random forest, xgboost dan lightgbm dalam klasifikasi emosi komentar reddit,” Fakultas Sains dan Teknologi UIN Syarif HIdayatullah Jakarta, Jakarta, 2024.
Downloads
Published
2025-12-31
Issue
Section
Articles