Analisis Sentimen Terhadap Data Komentar Publik Mengenai Isu UU Pilkada 2024 Menggunakan Metode Naïve Bayes dan K-Nearest Neighbor
DOI:
https://doi.org/10.47065/jimat.v5i3.514Keywords:
Text Mining; Sentiment Analysis; 2024 Regional Head Election Law; Naïve Bayes; K-Nearest NeighborAbstract
The 2024 Regional Head Election Law (UU Pilkada) has become an important issue widely discussed in Indonesia, especially on the social media platform X. Various public comments related to this issue contain positive, negative, and neutral sentiments, reflecting public perceptions. This study aims to analyze the sentiment of public comments on the 2024 UU Pilkada using two machine learning methods: Naïve Bayes and K-Nearest Neighbor (K-NN). The dataset consists of 3864 comments divided into three sentiment classes: 1477 negative comments, 1385 neutral comments, and 1002 positive comments, all of which have undergone text preprocessing. Evaluation was conducted using k-fold cross-validation (k=10). The test results show that the Naïve Bayes method achieves the highest accuracy of 63.47%, while K-NN reaches 56.73%. The precision for negative sentiment is 56.84%, meaning that about 43% of the comments predicted as negative by the model are actually not negative. The recall for negative sentiment is 45.45%, indicating that the model only captures less than half of the actual negative comments. For neutral sentiment, the precision of 60.71% and recall of 66.23% suggest that the model performs fairly well in recognizing neutral comments, although there is still a 39.29% error. For positive sentiment, the precision of 55.55% and recall of 57.63% indicate errors in classifying positive comments. Overall, while the model can correctly classify a portion of the data, there is potential to improve accuracy for both the negative and positive classes.
Downloads
References
T. Winarti, H. Indriyawati, V. Vydia, and F. W. Christanto, “Performance comparison between naive bayes and k- nearest neighbor algorithm for the classification of Indonesian language articles,” IAES Int. J. Artif. Intell. IJ-AI, vol. 10, no. 2, p. 452, Jun. 2021, doi: 10.11591/ijai.v10.i2.pp452-457.
A. T. Dewi Septiani, A. P. Kuncoro, P. Subarkah, and R. Riyanto, “Perbandingan Kinerja Metode Naïve Bayes Classifier dan K-Nearest Neighbor pada Analisis Sentimen Ulasan Mobile Banking Jenius,” J. Krisnadana, vol. 3, no. 2, pp. 67–77, Jan. 2024, doi: 10.58982/krisnadana.v3i2.516.
F. M. D. Maharani, A. L. Hananto, S. S. Hilabi, F. N. Apriani, A. Hananto, and B. Huda, “Perbandingan Metode Klasifikasi Sentimen Analisis Penggunaan E-Wallet Menggunakan Algoritma Naïve Bayes dan K-Nearest Neighbor,” METIK J., vol. 6, no. 2, Art. no. 2, Dec. 2022, doi: 10.47002/metik.v6i2.372.
R. T. S. A. Putri, D. E. Ratnawati, and D. W. Brata, “Perbandingan Naive Bayes dan K-Nearest Neighbor untuk Analisis Sentimen Aplikasi Gapura UB Berdasarkan Ulasan Pengguna pada Playstore,” J. Pengemb. Teknol. Inf. Dan Ilmu Komput., vol. 7, no. 1, pp. 229–236, Feb. 2023.
D. Era, S. Andryana, and A. Rubhasy, “Perbandingan Algoritma Naïve Bayes Dan K-Nearest Neighbor pada Analisis Sentimen Pembukaan Pariwisata Di Masa Pandemi Covid 19,” J-SAKTI J. Sains Komput. Dan Inform., vol. 7, no. 1, Art. no. 1, Mar. 2023, doi: 10.30645/j-sakti.v7i1.590.
H. Taufiqqurrahman, F. T. Anggraeny, and M. M. A. Haromainy, “PERBANDINGAN ALGORITMA NAÏVE BAYES DAN K-NEAREST NEIGHBOR PADA ANALISIS SENTIMEN ULASAN APLIKASI MYPERTAMINA,” JATI J. Mhs. Tek. Inform., vol. 7, no. 6, Art. no. 6, 2023, doi: 10.36040/jati.v7i6.7801.
S. Alfaris and Kusnawi, “Komparasi Metode KNN dan Naive Bayes Terhadap Analisis Sentimen Pengguna Aplikasi Shopee,” Indones. J. Comput. Sci., vol. 12, no. 5, Oct. 2023, doi: 10.33022/ijcs.v12i5.3304.
- Azhar, - Siti Ummi Masruroh, - Luh Kesuma Wardhani, and - Okfalisa, “Perbandingan kinerja algoritma Naïve Bayes dan K-NN Pendekatan Lexicon pada Analisis Sentimen di Media Twitter (Peer Review).” Accessed: Apr. 09, 2025. [Online]. Available: https://repository.uin-suska.ac.id/26321/
Z. P. Putra and A. Nugroho, “Pebandingan Performa Naïve Bayes dan KNN pada Klasifikasi Teks Sentimen Jasa Ekspedisi,” JOINTECS J. Inf. Technol. Comput. Sci., vol. 6, no. 3, p. 145, Sep. 2021, doi: 10.31328/jointecs.v6i3.2635.
Solimun, A. A. R. Fernandes, Nurjannah, E. G. Erwinda, R. Hardianti, and L. H. Y. Arini, Metodologi Penelitian: Variabel Mining berbasis Big Data dalam Pemodelan Sistem untuk mengungkap Research Novelty. Universitas Brawijaya Press, 2023.
D. D. A. Yani, H. S. Pratiwi, and H. Muhardi, “Implementasi Web Scraping untuk Pengambilan Data pada Situs Marketplace,” J. Sist. Dan Teknol. Inf. JUSTIN, vol. 7, no. 4, p. 257, Oct. 2019, doi: 10.26418/justin.v7i4.30930.
D. R. Wahyuni, “ANALISIS SENTIMEN MASYARAKAT TERHADAP POLITIK DINASTI DI INDONESIA MENGGUNAKAN METODE K-NEAREST NEIGHBOR.pdf.” Repository UIN Suska, 2025. [Online]. Available: https://repository.uin-suska.ac.id/
S. Kaparang, D. R. Kaparang, and V. P. Rantung, “Analisis Sentimen New Normal Pada Masa Covid-19 Menggunakan Algoritma Naive Bayes Classifier,” JOINTER J. Inform. Eng., vol. 2, no. 01, Art. no. 01, Jun. 2021, doi: 10.53682/jointer.v2i01.33.
M. S. Mustafa, M. R. Ramadhan, and A. P. Thenata, “Implementasi Data Mining untuk Evaluasi Kinerja Akademik Mahasiswa Menggunakan Algoritma Naive Bayes Classifier,” Creat. Inf. Technol. J., vol. 4, no. 2, Art. no. 2, Jan. 2018, doi: 10.24076/citec.2017v4i2.106.
H. Azis, P. Purnawansyah, F. Fattah, and I. P. Putri, “Performa Klasifikasi K-NN dan Cross Validation pada Data Pasien Pengidap Penyakit Jantung,” Ilk. J. Ilm., vol. 12, no. 2, Art. no. 2, Aug. 2020, doi: 10.33096/ilkom.v12i2.507.81-86.
N. Vendyansyah and Y. A. Pranoto, “Perancangan Dan Pembuatan Aplikasi Untuk Mendeteksi Kemiripan Jawaban Menggunakan Cosine Similarity,” J. Tek., vol. 13, no. 1, Art. no. 1, Mar. 2021, doi: 10.30736/jt.v13i1.536.
M. R. Fahlevvi, “ANALISIS SENTIMEN TERHADAP ULASAN APLIKASI PEJABAT PENGELOLA INFORMASI DAN DOKUMENTASI KEMENTERIAN DALAM NEGERI REPUBLIK INDONESIA DI GOOGLE PLAYSTORE MENGGUNAKAN METODE SUPPORT VECTOR MACHINE,” J. Teknol. Dan Komun. Pemerintah., vol. 4, no. 1, pp. 1–13, Jun. 2022, doi: 10.33701/jtkp.v4i1.2701.
M. F. A. Halik, “Analisis Sentimen Masyarakat Indonesia Terhadap Kebijakan Pemerintah Dalam Menangani Pandemi Covid-19 Menggunakan Klasifikasi Random Forest pada Media Sosial Twitter,” Thesis, Universitas Hasanuddin, 2023. Accessed: Jun. 14, 2024. [Online]. Available: https://repository.unhas.ac.id/id/eprint/29102/
S. Adi Santoso Mola, S.T.,M.Kom, N. Dessy Rumlaklak, S. Kom., M.Kom, and D. Putri Novita Polly, S.Kom, Analisis Sentimen dengan Metode Random Forest. Kaizen Media Publishing, 2024.
D. Musfiroh, U. Khaira, P. E. P. Utomo, and T. Suratno, “Analisis Sentimen terhadap Perkuliahan Daring di Indonesia dari Twitter Dataset Menggunakan InSet Lexicon: Sentiment Analysis of Online Lectures in Indonesia from Twitter Dataset Using InSet Lexicon,” MALCOM Indones. J. Mach. Learn. Comput. Sci., vol. 1, no. 1, Art. no. 1, Mar. 2021, doi: 10.57152/malcom.v1i1.20.
Bila bermanfaat silahkan share artikel ini
Berikan Komentar Anda terhadap artikel Analisis Sentimen Terhadap Data Komentar Publik Mengenai Isu UU Pilkada 2024 Menggunakan Metode Naïve Bayes dan K-Nearest Neighbor
ARTICLE HISTORY
Issue
Section
Copyright (c) 2025 Sebastianus Adi Santoso Mola, Yulianto Triwahyuadi Polly, Yosefa Carela Atok

This work is licensed under a Creative Commons Attribution 4.0 International License.
Authors who publish with this journal agree to the following terms:
- Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under Creative Commons Attribution 4.0 International License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (Refer to The Effect of Open Access).













