Sentiment Analysis of YouTube Comments Using the K-Nearest Neighbors (KNN) Method from an Axiological Perspective

Authors

  • Merinda Lestandy Department of Electrical Engineering, Universitas Muhammadiyah Malang, 65144, Indonesia Author
  • Syaad Patmanthara Department of Electrical Engineering and Informatics, Universitas Negeri Malang, 65145, Indonesia Author

DOI:

https://doi.org/10.51747/energy.si2025.257

Keywords:

Sentiment Analysis, YouTube, K-Nearest Neighbor, K-Means, Text Preprocessing, Model Accuracy, Axiology

Abstract

The rapid development of social media as a space for digital interaction has increased the need for sentiment analysis to understand public opinion in a systematic and measurable way. This study analyzes YouTube comment sentiment using the K-Nearest Neighbor (K-NN) method while also examining the axiological value of applying this technology in support of a more ethical digital ecosystem. The dataset consists of 8,200 YouTube comments obtained from Kaggle without predefined sentiment labels. The data were preprocessed through case folding, tokenization, stopword removal, stemming, and normalization. Initial sentiment labels were generated automatically using K-Means clustering to form two classes—positive and negative—and were partially verified manually. The labeled data were split into training and testing sets with ratios of 50:50, 60:40, 70:30, and 80:20, and evaluated using K-NN with k values of 3, 5, 7, and 9. Model performance was assessed using a confusion matrix with accuracy, precision, recall, and F1-score metrics. The results show that accuracy ranges from 0.95 to 0.96, with the best performance achieved at a 70:30 split and an optimal k value yielding 0.96 accuracy. Beyond technical contributions, this study highlights the ethical and practical value of sentiment analysis for interpreting public opinion, supporting fairer content moderation, and improving communication quality in social media environments.

References

[1] L. Yue, W. Chen, X. Li, W. Zuo, and M. Yin, “A survey of sentiment analysis in social media,” Knowl Inf Syst, vol. 60, no. 2, pp. 617–663, 2019, doi: 10.1007/s10115-018-1236-4.

[2] S. Chaudhary, K. Garg, P. Gupta, and A. K. Dwivedi, “Social Media Sentiment Analysis for Airline Customer Satisfaction,” Institute of Electrical and Electronics Engineers Inc., 2025, pp. 1519–1522. doi: 10.1109/ICDT63985.2025.10986313.

[3] B. Pithava, A. Magar, and S. Bharti, “Unveiling Sentiment Dynamics: Emotion Detection in Social Media,” Institute of Electrical and Electronics Engineers Inc., 2024. doi: 10.1109/ICEC59683.2024.10837523.

[4] N. Abel Laia and S. P. Barus, “Analisis Sentimen YouTube: ‘Di Balik Ambisi Jokowi dalam IKN,’” Jurnal Pustaka AI (Pusat Akses Kajian Teknologi Artificial Intelligence), vol. 5, no. 1, pp. 07–12, Apr. 2025, doi: 10.55382/jurnalpustakaai.v5i1.891.

[5] V. S. Sherlin Solomi, S. N. Rajana, M. M. Kolluri, and W. J. William, “Deep learning based opinion mining on youtube,” in AIP Conference Proceedings, American Institute of Physics, 2024. doi: 10.1063/5.0209061.

[6] A. Rahman, F. Rahmat, M. Y. Fariqi, and S. Adi, “Metode Naive Bayes untuk Menganalisis Akurasi Sentimen Komentar di Youtube,” 2020. [Online]. Available: http://bit.ly/2u802Pe

[7] D. N. Larasakti, A. Aziz, and D. Aditya, “Analisis Sentimen Komentar Video Youtube Dengan Metode K-Nearest Neighbor,” Jurnal Ilmiah Wahana Pendidikan, vol. 2023, no. 5, pp. 132–142, doi: 10.5281/zenodo.7728573.

[8] M. Cindo, D. P. Rini, and E. Ermatita, “Literatur Review: Metode Klasifikasi Pada Sentimen Analisis,” Seminar Nasional Teknologi …, 2019, [Online]. Available: http://seminar-id.com/prosiding/index.php/sainteks/article/view/124

[9] S. F. Pratama, R. Andrean, and ..., “Analisis Sentimen Twitter Debat Calon Presiden Indonesia Menggunakan Metode Fined-Grained Sentiment Analysis,” JOINTECS (Journal …, 2019, [Online]. Available: http://publishing-widyagama.ac.id/ejournal-v2/index.php/jointecs/article/view/1004

[10] M. R. Firdaus, F. M. Rizki, F. M. Gaus, and ..., “Analisis Sentimen Dan Topic Modelling Dalam Aplikasi Ruangguru,” J-SAKTI (Jurnal Sains …, 2020, [Online]. Available: http://ejurnal.tunasbangsa.ac.id/index.php/jsakti/article/view/188

[11] K. B. Reddy, D. Sai Parthava Naidu, N. Deekshitha, and M. Srinivas, “Exploring Hybrid Approaches for Sentiment Classification: A Comparative Study of LSTM, Naive Bayes, and Bayesian Network on IMDB Reviews,” Institute of Electrical and Electronics Engineers Inc., 2025, pp. 221–227. doi: 10.1109/AIDE64228.2025.10987367.

[12] “Comparative Analysis of Lexicon-Based Emotion Recognition of Text,” 2023, pp. 671–677. doi: 10.1007/978-981-19-5868-7_49.

[13] Y. Dong and X. Zeng, “Lexicon-Enhanced Multi-Task Convolutional Neural Network for Emotion Distribution Learning,” Axioms, vol. 11, no. 4, 2022, doi: 10.3390/axioms11040181.

[14] N. Ruhyana and D. Rosiyadi, “Klasifikasi Komentar Instagram untuk Identifikasi Keluhan Pelanggan Jasa Pengiriman Barang dengan Metode SVM dan Naïve Bayes Berbasis Teknik Smote,” Faktor Exacta, vol. 12, no. 4, p. 280, 2020, doi: 10.30998/faktorexacta.v12i4.4981.

[15] R. Danyana Umrona, S. Naja Anwar, and R. Soelistijadi, “ANALISIS SENTIMEN KOMENTAR YOUTUBE TERKAIT KASUS PAGAR LAUT MENGGUNAKAN METODE KNN (K-NEAREST NEIGHBOR),” Jurnal Informatika Teknologi dan Sains.

[16] S. A. Amira and M. I. Irawan, “Opinion Analysis of Traveler Based on Tourism Site Review Using Sentiment Analysis,” IPTEK The Journal for Technology and Science, vol. 31, no. 2, p. 223, 2020, doi: 10.12962/j20882033.v31i2.6338.

[17] M. R. Firmansyah, R. Ilyas, and F. Kasyidi, “Klasifikasi Kalimat Ilmiah Menggunakan Recurrent Neural Network,” Prosiding The 11th Industrial Research Workshop and National Seminar, vol. 11, no. 1, pp. 488–495, 2020.

[18] I. L. Rais and J. Jondri, “Klasifikasi Data Kuesioner dengan Metode Recurrent Neural Network,” eProceedings of Engineering, vol. 7, no. 1, pp. 2817–2826, 2020.

[19] E. B. Nugroho, M. T. Furqon, and N. Hidayat, “Klasifikasi Pendonor Darah Menggunakan Metode Support Vector Machine,” Jurnal Pengembangan Teknologi Informasi dan Ilmu Komputer (J-PTIIK) Universitas Brawijaya, vol. 2, no. 10, pp. 3860–3864, 2018.

[20] N. K. Widyasanti, I. K. G. Darma Putra, and N. K. Dwi Rusjayanthi, “Seleksi Fitur Bobot Kata dengan Metode TFIDF untuk Ringkasan Bahasa Indonesia,” Jurnal Ilmiah Merpati (Menara Penelitian Akademika Teknologi Informasi), vol. 6, no. 2, p. 119, 2018, doi: 10.24843/jim.2018.v06.i02.p06.

[21] I. Kurniawan and A. Susanto, “Implementasi Metode K-Means dan Naïve Bayes Classifier untuk Analisis Sentimen Pemilihan Presiden (Pilpres) 2019,” Jurnal Eksplora Informatika, 2019, [Online]. Available: https://eksplora.stikom-bali.ac.id/index.php/eksplora/article/view/237

[22] U. Kasanah, A. N., Muladi, M., & Pujianto, “Penerapan Teknik SMOTE untuk Mengatasi Imbalance Class dalam Klasifikasi Objektivitas Berita Online Menggunakan Algoritma KNN,” Jurnal RESTI (Rekayasa Sistem Dan Teknologi Informasi), vol. 1, no. 3, pp. 196–201, 2019.

[23] M. Syarifuddin, “Analisis Sentimen Opini Publik Mengenai Covid-19 Pada Twitter Menggunakan Metode Naïve Bayes Dan Knn,” Inti Nusa Mandiri, vol. 15, no. 1, pp. 23–28, 2020.

[24] M. R. Braun, P. Walton, S. B. M. Beck, and W. London, “Illustrating the relationship between the coefficient of performance and the coefficient of system performance by means of an R404 supermarket refrigeration system,” International Journal of Refrigeration, vol. 70, pp. 225–234, 2016, doi: 10.1016/j.ijrefrig.2015.10.020.

[25] Z. Ma, H. Bao, and A. P. Roskilly, “Thermodynamic modelling and parameter determination of ejector for ejection refrigeration systems,” International Journal of Refrigeration, vol. 75, pp. 117–128, 2017, doi: 10.1016/j.ijrefrig.2016.12.005.

Downloads

Published

2025-12-30

How to Cite

Sentiment Analysis of YouTube Comments Using the K-Nearest Neighbors (KNN) Method from an Axiological Perspective. (2025). ENERGY: JURNAL ILMIAH ILMU-ILMU TEKNIK, 436-451. https://doi.org/10.51747/energy.si2025.257