Klasifikasi Tingkat Serangan pada Log Jaringan Siber dengan Komparasi Naive Bayes dan K-Nearest Neighbor
Abstract
The increasing threat of cybersecurity poses a significant impact on both organizations and individuals, necessitating a system capable of accurately detecting and classifying attack levels to support prioritization of responses. This study aims to analyze and compare the performance of two machine learning algorithms, Naive Bayes and K-Nearest Neighbor (KNN), in classifying cyberattack levels, and to evaluate the effect of hyperparameter tuning on improving model accuracy. The research methods included utilizing the cybersecurity_attacks dataset, data preprocessing, model training at three data split ratios (70:30, 80:20, and 90:10), and parameter optimization using Randomized Search and Grid Search. Performance evaluation was based on accuracy, precision, recall, and F1-score values. The results showed that KNN performed best, with a peak accuracy of 0.96 at the 80:20 ratio after tuning, increased from an accuracy of 0.947 before tuning, with precision, recall, and F1-score values ranging from 0.95 to 0.96. Meanwhile, Naive Bayes only achieved a peak accuracy of 0.8485 at the same ratio. Although the improvement after hyperparameter tuning was not significant, this process still resulted in a more stable and consistent model. Future research is recommended to explore ensemble methods and test them on other datasets to produce more adaptive cyberattack classification models.
Downloads
References
E. S. P. Sinlae, I. F. Syahda, and A. U. Hosnah, “Kriminalitas Cyber Bjorka: Ancaman dan Tantangan di Era Digital,” Jurnal Justitia: Jurnal Ilmu Hukum dan Humaniora, vol. 7, no. 1, pp. 208–289, 2024, doi: http://dx.doi.org/10.31604/justitia.v7i1.280-289.
E. M. Kala, “The Impact of Cyber Security on Business: How to Protect Your Business,” Open Journal of Safety Science and Technology, vol. 13, no. 02, pp. 51–65, 2023, doi: 10.4236/ojsst.2023.132003.
T. G. Laksana and S. Mulyani, “Pengetahuan Dasar Identifikasi Dini Deteksi Serangan Kejahatan Siber Untuk Mencegah Pembobolan Data Perusahaan,” Jurnal Ilmiah Multidisiplin (JUKIM), vol. 3, no. 1, pp. 109–122, Jan. 2024, doi: 10.56127/jukim.v3i01.1143.
I. P. Putri, Terttiaavini, and N. Arminarahmah, “Analisis Perbandingan Algoritma Machine Learning untuk Prediksi Stunting pada Anak,” MALCOM: Indonesian Journal of Machine Learning and Computer Science, vol. 4, no. 1, pp. 257–265, Jan. 2024, doi: 10.57152/malcom.v4i1.1078.
A. F. Mahmud and S. Wirawan, “Deteksi Phishing Website menggunakan Machine Learning Metode Klasifikasi,” Sistemasi: Jurnal Sistem Informasi, vol. 13, no. 4, pp. 1368–1380, 2024, doi: 10.32520/stmsi.v13i4.3456.
R. B. Hadiprakoso, W. R. Aditya, and F. N. Pramitha, “Analisis Statis Deteksi Malware Android Menggunakan Algoritma Supervised Machine Learning,” Cyber Security dan Forensik Digital, vol. 5, no. 1, pp. 1–5, May 2022, doi: 10.14421/csecurity.. 2022.5.1.3116.
A. Fauzi et al., “Penerapan Random Forest dan Adaboost untuk Klasifikasi Serangan DDoS,” Journal on Education, vol. 05, no. 03, pp. 7925–7937, 2023, doi: 10.31004/joe.v5i3.1920.
K. B. Dasari and N. Devarakonda, “Detection of DDoS Attacks Using Machine Learning Classification Algorithms,” International Journal of Computer Network and Information Security, vol. 14, no. 6, pp. 89–97, Dec. 2022, doi: 10.5815/ijcnis.. 2022.06.07.
J. Naufal Semendawai, D. Stiawan, and I. Pahendra, “Shellcode Classification with Machine Learning Based on Binary Classification,” Indonesia Journal of Social Technology, vol. 6, no. 2, pp. 833–844, Feb. 2025, doi: 10.59141/jist.v6i2.3233.
Herman, I. Riadi, and Y. Kurniawan, “Vulnerability Detection With K-Nearest Neighbor and Naïve Bayes Method using Machine Learning,” International Journal of Artificial Intelligence Research, vol. 7, no. 1, pp. 10–18, Jun. 2023, doi: 10.29099/ijair.v7i1.795.
D. Hindarto, R. E. Indrajit, and E. Dazki, “Perbandingan Kinerja Akurasi Klasifikasi K-NN, NB dan DT Pada APK Android,” JATISI (Jurnal Teknik Informatika dan Sistem Informasi), vol. 9, no. 1, pp. 486–503, Mar. 2022, doi: 10.35957/jatisi.v9i1.1542.
A. D. Afifaturahman and F. Maulana, “Perbandingan Algoritma K-Nearest Neighbour (KNN) dan Naive Bayes pada Intrusion Detection System (IDS),” Innovation in Research of Informatics (INNOVATICS), vol. 3, no. 1, pp. 17–25, 2021, doi: 10.37058/innovatics.v3i1.2852.
S. Junaidi, R. V. Anggela, and D. Kariman, “Klasifikasi Metode Data Mining untuk Prediksi Kelulusan Tepat Waktu Mahasiswa dengan Algoritma Naïve Bayes, Random Forest, Support Vector Machine (SVM) dan Artificial Neural Nerwork (ANN),” Journal of Applied Computer Science and Technology (JACOST), vol. 5, no. 1, pp. 109–119, Jun. 2024, doi: 10.52158/jacost.v5i1.489.
S. R. Cholil, T. Handayani, R. Prathivi, and T. Ardianita, “Implementasi Algoritma Klasifikasi K-Nearest Neighbor (KNN) Untuk Klasifikasi Seleksi Penerima Beasiswa,” IJCIT (Indonesian Journal on Computer and Information Technology), vol. 6, no. 2, pp. 118–127, 2021, doi: 10.31294/ijcit.v6i2.10438.
G. L. Pritalia, “Analisis Komparatif Algoritme Machine Learning pada Klasifikasi Kualitas Air Layak Minum,” KONSTELASI: Konvergensi Teknologi dan Sistem Informasi, vol. 2, no. 1, pp. 43–55, Apr. 2022, doi: 10.24002/konstelasi.v2i1.5630.
Y. E. J. Putra, I. Imelda, and S. Suryadih, “Seleksi Fitur SelectKBest Dalam Prediksi Kelulusan Mahasiswa Tepat Waktu dengan Decision Tree,” Building of Informatics, Technology and Science (BITS), vol. 6, no. 4, pp. 2776–2784, Mar. 2025, doi: 10.47065/bits.v6i4.7086.
R. M. Sari et al., Klasifikasi Data Mining. Serasi Media Teknologi, 2024. [Online]. Available: https://www.google.co.id/books/edition/Klasifikasi_Data_Mining/xTwXEQAAQBAJ?hl=id&gbpv=0
N. Febriyanti and A. F. Rozi, “Komparasi Algoritma Naïve Bayes, Support Vector Machine, dan Random Forest Untuk Analisis Sentimen Ulasan Pengguna Aplikasi CGV Cinemas Indonesia,” Building of Informatics, Technology and Science (BITS), vol. 7, no. 1, pp. 453–464, Jun. 2025, doi: 10.47065/bits.v7i1.7459.
Mustika et al., Data Mining dan Aplikasinya. Bandung: Widina Bhakti Persada Bandung, 2021. [Online]. Available: https://www.google.co.id/books/edition/DATA_MINING_DAN_APLIKASINYA/53FXEAAAQBAJ?hl=id&gbpv=0
R. A. Nolly, A. Fitria, and K. Saputra S, “Penerapan Algoritma K-Nearest Neighbors untuk Klasifikasi Fragmen Metagenom Berdasarkan Ekstraksi Fitur K-Mers,” Informatika Mulawarman : Jurnal Ilmiah Ilmu Komputer, vol. 17, no. 1, pp. 52–56, Feb. 2023, doi: 10.30872/jim.v17i1.5779.
V. Sianipar, D. Irmayani, and B. Bangun, “Analisis Faktor-Faktor yang Mempengaruhi Tingkat Kelulusan Siswa Menggunakan Algoritma KNN,” Building of Informatics, Technology and Science (BITS), vol. 7, no. 1, pp. 626–637, Jun. 2025, doi: 10.47065/bits.v7i1.7386.
N. M. Putry and B. N. Sari, “Komparasi Algoritma KNN dan Naïve Bayes Untuk Klasifikasi Diagnosis Penyakit Diabetes Melitus,” Evolusi: Jurnal Sains dan Manajemen, vol. 10, no. 1, pp. 45–57, Sep. 2022, doi: 10.31294/evolusi.v10i1.12514.
R. A. Putra, Langkah Mudah Belajar Machine Learning dengan Python untuk Pemula. Yogyakarta: Anak Hebat Indonesia, 2024. [Online]. Available: https://www.google.co.id/books/edition/Langkah_Mudah_Belajar_Machine_Learning_D/JulyEQAAQBAJ?hl=id&gbpv=0&kptab=overview
A. J. Himawan, A. M. K. Sari, N. A. Parsa, K. S. P. Hermansyah, and E. S. D. Rizki, “Penerapan Metode K-Nearest Neighbors dalam Mendeteksi Website Phishing,” Jurnal Kecerdasan Buatan, Komputasi dan Teknologi Informasi, vol. 5, no. 2, pp. 167–173, Dec. 2024, doi: 10.33650/coreai.v5i2.10484.
P. Padman, Learn Data Science from Scratch: Mastering ML and NLP with Python in a Step-by-step Approach (English Edition), 1st ed. BPB Publications, 2024. [Online]. Available: https://www.google.co.id/books/edition/Learn_Data_Science_from_Scratch/rhX1EAAAQBAJ?hl=id&gbpv=0
L. Owen, Hyperparameter Tuning with Python: Boost Your Machine Learning Model’s Performance Via Hyperparameter Tuning, 1st Edition. Packt Publishing, 2022. [Online]. Available: https://www.google.co.id/books/edition/_/CqF-EAAAQBAJ?hl=id&gbpv=1
A. R. Arsyan and W. F. Al Maki, “Classification of Glaucoma Using Invariant Moment Methods on K-Nearest Neighbor and Random Forest Models,” Building of Informatics, Technology and Science (BITS), vol. 3, no. 4, pp. 466–472, Mar. 2022, doi: 10.47065/bits.v3i4.1244.
A. M. Halim, M. Dwifebri, and F. Nhita, “Handling Imbalanced Data Sets Using SMOTE and ADASYN to Improve Classification Performance of Ecoli Data Sets,” Building of Informatics, Technology and Science (BITS), vol. 5, no. 1, pp. 246–253, Jun. 2023, doi: 10.47065/bits.v5i1.3647.
N. Soprala, D. Sinnreich, N. Kumar, and S. Furqhan, “Anomaly Detection in Streaming Time Series Data with Online Learning using Amazon Managed Service for Apache Flink,” aws.amazon.com. Accessed: Sep. 22, 2025. [Online]. Available: https://aws.amazon.com/blogs/machine-learning/anomaly-detection-in-streaming-time-series-data-with-online-learning-using-amazon-managed-service-for-apache-flink/
R. Blanquero, E. Carrizosa, P. Ramírez-Cobo, and M. R. Sillero-Denamiel, “Variable Selection for Naïve Bayes Classification,” Computers and Operations Research 135, Jul. 2021, doi: 10.1016/j.cor.2021.105456.
Bila bermanfaat silahkan share artikel ini
Berikan Komentar Anda terhadap artikel Klasifikasi Tingkat Serangan pada Log Jaringan Siber dengan Komparasi Naive Bayes dan K-Nearest Neighbor
Pages: 1974-1985
Copyright (c) 2025 Evinda Apriliani, Sri Winiarti, Imam Riadi, Herman Yuliansyah

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).





















