Implementation of the K-Nearest Neighbors Algorithm for Spam Email Classification
DOI:
https://doi.org/10.36085/jsai.v8i1.7531Abstract
In modern life, internet access has become essential for communication. Email is one of many communication tools. Cyberattacks such as ransomware, phishing, and cryptojacking continue to evolve and are difficult to detect by security systems as technology rapidly advances. Therefore, this study uses email spam as the subject of research. The aim of this study is to implement and calculate the accuracy of the K-Nearest Neighbors (KNN) algorithm in classifying spam emails with ham and spam labels. An accuracy of 85%, precision of 87%, recall of 93%, and F1-score of 90% were obtained from tests conducted with an 80% training data and 20% testing data ratio. The results show that the K-Nearest Neighbors algorithm can effectively classify spam emails.
Downloads
Published
Issue
Section
License
Copyright (c) 2025 Diani Putri Kusumaningrum, Ahmad Turmudi Zy, Suprapto

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