Naive Bayes Algorithm with Feature Selection Using Particle Swarm Optimization

  • Siswanto Siswanto Universitas Hasanuddin, Indonesia
  • Iwan Kurniawan Universitas Hasanuddin, Indonesia
  • Sri Astuti Thamrin Universitas Hasanuddin, Indonesia
Keywords: COVID-19; Classification; Naïve bayes; particle swarm optimization; Twitter.


The COVID-19 vaccine in Indonesia has led to the emergence of public opinion which is conveyed on social media such as Twitter. One of the analyses that can be done to produce various information from public opinion is sentiment analysis. Sentiment analysis is used to determine whether an opinion tends to be positive or negative. This study aims to classify the public opinion of the COVID-19 vaccine in Indonesia with sentiment analysis and to visualize the location of the sentiment of the COVID-19 vaccine tweet data in Indonesia. To achieve this aim, the Naïve Bayes algorithm with Particle Swarm Optimization (PSO) feature selection was used. This study uses opinions into positive and negative class sentiments towards 2,547 tweets related to the COVID-19 vaccine in Indonesia from January to June 2021. The results show that the distribution of positive and negative class sentiments is 2,328 and 219, respectively. In addition, the positive sentiment for the COVID-19 vaccine was dominated by people on the island of Java based on a random number matrix initialized by the PSO method. The classification of public opinion on Twitter media provides accurate and optimal performance results using a combination of the Naïve Bayes algorithm with PSO feature selection. The results of the combination of these methods have accuracy and F1 score values of 91.28% and 95.38%, respectively. The visualization of geo-spatial mapping showed that positive sentiments related to the COVID-19 vaccine exist in almost all regions in Indonesia but are dominated by the Jabodetabek area.


Ahmed, Zahid, Biju Issac, & Sufal Das. Ok-NB: An Enhanced OPTICS and k-Naive Bayes Classifier for Imbalance Classification with Overlapping. IEEE Access (2024). doi. 10.1109/ACCESS.2024.3391749.
Alsaeedi, Abdullah, & Khan, Mohammad Zubair. (2019). A Study on Sentiment Analysis Techniques of Twitter Data. IJACSA) International Journal of Advanced Computer Science and Applications, 10(2).
Bahri, Muhammad Syamsul, Hermawan, Agus, Pricilia Kondy, Evlyn, Joyce Semida, Refa, & Siswanto. (2022). Performance Comparison of Supporting Vector Machine Method without or with Particle Swarm Optimization Based on Sentiment Analysis WhatsApp Review. International Journal of Academic and Applied Research, 6(6), 94–101.
Bowdle, Andrew, & Munoz-Price, L. Silvia. (2020). Preventing Infection of Patients and Healthcare Workers Should Be the New Normal in the Era of Novel Coronavirus Epidemics. Anesthesiology, 132(6), 1292–1295.
Claudy, Yessivha Imanuela, Setya Perdana, Rizal, & Fauzi, M. Ali. (2018). Klasifikasi Dokumen Twitter Untuk Mengetahui Karakter Calon Karyawan Menggunakan Algoritme K-Nearest Neighbor (KNN). Jurnal Pengembangan Teknologi Informasi Dan Ilmu Komputer, 2(8), 2761–2765.
Effendy, Veronikha. (2015). Analisis Sentimen Berbahasa Indonesia Dengan Pendekatan Lexicon Based (Studi Kasus: Solusi Pengelolaan Sampah). Jurnal Ilmiah Komputer Dan Informatika (KOMPUTA), 55(1).
Fanissa, Shima, Fauzi, M. Ali, & Adinugroho, Sigit. (2018). Analisis Sentimen Pariwisata di Kota Malang Menggunakan Metode Naive Bayes dan Seleksi Fitur Query Expansion Ranking. Jurnal Pengembangan Teknologi Informasi Dan Ilmu Komputer, 2(8), 2766–2770.
Hickman, Louis, Thapa, Stuti, Tay, Louis, Cao, Mengyang, & Srinivasan, Padmini. (2022). Text Preprocessing for Text Mining in Organizational Research: Review and Recommendations. Organizational Research Methods, 25(1), 114–146.
Hyuningtyas, Ratih Yulia, Retno Sari, and Wina Yusnaeni. Particle swarm optimization for feature selection in sentiment analysis on the application of digital payments OVO using the algorithm of Naive Bayes. AIP Conference Proceedings. Vol. 2714. No. 1. AIP Publishing, 2023.
Khder, Moaiad. (2021). Web Scraping or Web Crawling: State of Art, Techniques, Approaches and Application. International Journal of Advances in Soft Computing and Its Applications, 13(3), 145–168.
Lyu, Joanne Chen, Eileen Le Han, & Garving K. Luli. COVID-19 vaccine–related discussion on Twitter: topic modeling and sentiment analysis. Journal of medical Internet research 23.6 (2021): e24435. doi:10.2196/24435.
Mazdadi, Muhammad Itqan, Andi Farmadi, and Dwi Kartini. Implementation of Particle Swarm Optimization Feature Selection on Naïve Bayes for Thoracic Surgery Classification. Journal of Electronics, Electromedical Engineering, and Medical Informatics 5.3 (2023): 150-158.
Palanisamy, Tamilselvi, Sadayan, Geetha, & Pathinetampadiyan, Nagasankar. (2022). Neural network–based leaf classification using machine learning. Concurrency and Computation: Practice and Experience, 34(8).
Papazoglou, G. and Biskas, P., 2023. Review and comparison of genetic algorithm and particle swarm optimization in the optimal power flow problem. Energies, 16(3), p.1152.
Sağlam, Fatih, and Mehmet Ali Cengiz. Local resampling for locally weighted Naïve Bayes in imbalanced data. Computing 106.1 (2024): 185-200.
Tijjani, Sani, Mohd Nadhir Ab Wahab, and Mohd Halim Mohd Noor. An enhanced particle swarm optimization with position update for optimal feature selection. Expert Systems with Applications 247 (2024): 123337.
How to Cite
S. Siswanto, I. Kurniawan, and S. A. Thamrin, “Naive Bayes Algorithm with Feature Selection Using Particle Swarm Optimization”, Jurnal Varian, vol. 7, no. 2, pp. 127 - 136, Jun. 2024.

Most read articles by the same author(s)