Support vector machine with n-gram features for detecting Indonesian hate comments on YouTube
Keywords:
Hate speech detection, Indonesian YouTube, N-gram feature extraction, Support vector machine (SVM), Text classification, TF-IDFAbstract
The use of social media has been massively increasing. As technology enables rapid information dissemination, the challenge of hate speech, which can lead to cybercrime and societal division, emerges. This study proposes a hate speech detection model using Support Vector Machine (SVM) and n-gram feature extraction to classify Indonesian YouTube comments into hate and non-hate categories. The research classifies 2.727 comments from Indonesian YouTuber into hate comments and non-hate comment categories. Model training is conducted using unigram, bigram, and trigram as the features. Optimal hyperparameters are determined through grid search, and model performance is evaluated using a confusion matrix. Results show that the unigram model achieved the highest accuracy (70.45%), the trigram model achieved the highest recall (93.06%) but at the cost of lower accuracy, while the bigram model provided the best balance with an F1-score of 71.00%. These findings demonstrate the importance of feature selection in enhancing SVM-based text classification and highlight the effectiveness of bigram features for robust hate speech detection in Indonesian YouTube comments.
References
[1] S. Kemp, “DIGITAL 2023: GLOBAL OVERVIEW REPORT,” Global, Jan. 2023. Accessed: May 10, 2023. [Online]. Available: https://datareportal.com/reports/digital-2023-global-overview-report
[2] A. F. Azhar and E. Soponyono, “Kebijakan Hukum Pidana dalam Pengaturan dan Penanggulangan Ujaran Kebencian (Hate Speech) di Media Sosial Criminal Law Policy in the Regulation and Prevention of Hate Speech on Social Media,” Jurnal Pembangunan Hukum Indonesia, vol. 2, no. 2, pp. 275–290, May 2020, doi: 10.14710/JPHI.V2I2.275-290.
[3] F. Alkomah and X. Ma, “A Literature Review of Textual Hate Speech Detection Methods and Datasets,” Information 2022, Vol. 13, Page 273, vol. 13, no. 6, p. 273, May 2022, doi: 10.3390/INFO13060273.
[4] M. Putri, K. Dewi, and E. B. Setiawan, “Feature Expansion Using Word2vec for Hate Speech Detection on Indonesian Twitter with Classification Using SVM and Random Forest,” JURNAL MEDIA INFORMATIKA BUDIDARMA, vol. 6, no. 2, pp. 979–988, Apr. 2022, doi: 10.30865/MIB.V6I2.3855.
[5] A. Gasparetto, M. Marcuzzo, A. Zangari, and A. Albarelli, “ Survey on Text Classification Algorithms: From Text to Predictions,” Information (Switzerland), vol. 13, no. 2, Feb. 2022, doi: 10.3390/info13020083.
[6] M. A. Cano Lengua and E. A. Papa Quiroz, “A Systematic Literature Review on Support Vector Machines Applied to Classification,” in Proceedings of the 2020 IEEE Engineering International Research Conference, EIRCON 2020, Institute of Electrical and Electronics Engineers Inc., Oct. 2020. doi: 10.1109/EIRCON51178.2020.9254028.
[7] R. Hendrawan, Adiwijaya, and S. Al Faraby, “Multilabel Classification of Hate Speech and Abusive Words on Indonesian Twitter Social Media,” in 2020 International Conference on Data Science and Its Applications (ICoDSA), 2020, pp. 1–7. doi: 10.1109/ICoDSA50139.2020.9212962.
[8] A. Zikri and S. Agustian, “Penerapan Support Vector Machine dan FastText untuk Mendeteksi Hate Speech dan Abusive pada Twitter,” Jurnal Media Informatika Budidarma, vol. 7, no. 1, pp. 436–443, 2023, doi: 10.30865/mib.v7i1.5408.
[9] O. H. Rahman, G. Abdillah, and A. Komarudin, “Klasifikasi Ujaran Kebencian pada Media Sosial Twitter Menggunakan Support Vector Machine Hate Speech Classification on Twitter Using Support Vector Machine,” Jurnal RESTI (Rekayasa Sistem dan Teknologi Informasi), vol. 5, no. 1, pp. 17–23, Feb. 2021, doi: 10.29207/RESTI.V5I1.2700.
[10] Y. Vernanda, S. Hansun, and M. B. Kristanda, “Indonesian language email spam detection using n-gram and naïve bayes algorithm,” Bulletin of Electrical Engineering and Informatics, vol. 9, no. 5, pp. 2012–2019, Oct. 2020, doi: 10.11591/eei.v9i5.2444.
[11] M. T. Ahmed, M. Rahman, S. Nur, A. Z. M. T. Islam, and D. Das, “Natural language processing and machine learning based cyberbullying detection for Bangla and Romanized Bangla texts,” Telkomnika (Telecommunication Computing Electronics and Control), vol. 20, no. 1, pp. 89–97, Feb. 2022, doi: 10.12928/TELKOMNIKA.v20i1.18630.
[12] T. N. Manoppo and D. H. Fudholi, “Deteksi Cyberbullying berdasarkan Unsur Perbuatan Pidana yang Dilanggar dengan Naive Bayes dan Support Vector Machine Cyberbullying Detection Based on Criminal Act Elements Using Naïve Bayes and Support Vector Machine,” J-SAKTI (Jurnal Sains Komputer dan Informatika), vol. 5, no. 1, pp. 10–19, Mar. 2021, doi: 10.30645/J-SAKTI.V5I1.293.
[13] Asogwa DC, Chukwuneke CI, Ngene CC, and Anigbogu GN, “Hate Speech Classification Using SVM and Naive BAYES,” IOSR-Journal of Mobile Computing & Application, vol. 9, no. 1, pp. 27–34, 2022, doi: 10.9790/0050-09012734.
[14] D. M. Belete and M. D. Huchaiah, “Grid search in hyperparameter optimization of machine learning models for prediction of HIV/AIDS test results,” International Journal of Computers and Applications, vol. 44, no. 9, pp. 875–886, 2022, doi: 10.1080/1206212X.2021.1974663.
[15] U. Naseem, I. Razzak, and P. W. Eklund, “A survey of pre-processing techniques to improve short-text quality: a case study on hate speech detection on twitter,” Multimed Tools Appl, vol. 80, no. 28, pp. 35239–35266, 2021, doi: 10.1007/s11042-020-10082-6.
[16] W. Haitao, H. Jie, Z. Xiaohong, and L. Shufen, “A short text classification method based on n-gram and cnn,” Chinese Journal of Electronics, vol. 29, no. 2, pp. 248–254, Mar. 2020, doi: 10.1049/cje.2020.01.001.
[17] Q. Li et al., “A Survey on Text Classification: From Traditional to Deep Learning,” ACM Trans Intell Syst Technol, vol. 13, no. 2, Apr. 2022, doi: 10.1145/3495162.
[18] L. Hickman, S. Thapa, L. Tay, M. Cao, and P. Srinivasan, “Text Preprocessing for Text Mining in Organizational Research: Review and Recommendations,” Organ Res Methods, vol. 25, no. 1, pp. 114–146, Jan. 2022, doi: 10.1177/1094428120971683.
[19] S. Chandrayan and P. Bamne, “A brief survey of Text Mining and its applications,” International Journal of Emerging Trends in Engineering Research, vol. 9, no. 8, pp. 1190–1195, Aug. 2021, doi: 10.30534/ijeter/2021/26982021.
[20] I. S. Al-Mejibli, J. K. Alwan, and D. H. Abd, “The effect of gamma value on support vector machine performance with different kernels,” International Journal of Electrical and Computer Engineering, vol. 10, no. 5, pp. 5497–5506, Oct. 2020, doi: 10.11591/IJECE.V10I5.PP5497-5506.
[21] A. Kowalczyk, Support Vector Machine Succinctly. Morrisville: Syncfusion,Inc., 2017. [Online]. Available: www.syncfusion.com.
[22] D. A. Pisner and D. M. Schnyer, “Support vector machine,” in Machine Learning: Methods and Applications to Brain Disorders, Elsevier, 2019, pp. 101–121. doi: 10.1016/B978-0-12-815739-8.00006-7.
[23] I. S. Al-Mejibli, D. H. Abd, J. K. Alwan, and A. J. Rabash, “Performance evaluation of kernels in support vector machine,” in Proceedings - 2018 1st Annual International Conference on Information and Sciences, AiCIS 2018, Institute of Electrical and Electronics Engineers Inc., Feb. 2019, pp. 96–101. doi: 10.1109/AiCIS.2018.00029.
[24] A. Geron, Hands-on Machine Learning with Scikit-Learn, Keras, and TensorFlow Concepts, Tools, and Techniques to Build Intelligent Systems, 2nd ed. O’Relly Media, Inc., 2019.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 Dewi Soyusiawati, Mafatihul Hidayah, Muhammad Kunta Biddinika

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.




Indonesia
Nigeria
Iraq

