Implementation of the K-Nearest Neighbors Algorithm for Spam Email Classification

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.

Authors

Institutions

Publication Details

Journal
JSAI (Journal Scientific and Applied Informatics)
Published
2025-01-01
DOI
https://doi.org/10.36085/jsai.v8i1.7531
Primary Topic
Spam and Phishing Detection
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Implementation of the K-Nearest Neighbors Algorithm for Spam Email Classification

Ahmad Turmudi Zy, Suprapto Suprapto, Diani Putri Kusumaningrum
JSAI (Journal Scientific and Applied Informatics)
Spam and Phishing Detection
article

Implementation of the K-Nearest Neighbors Algorithm for Spam Email Classification

Ahmad Turmudi Zy, Suprapto Suprapto, Diani Putri Kusumaningrum
article en

Abstract

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.

JSAI (Journal Scientific and Applied Informatics)Vol. 8(1)
Universitas Nusa Bangsa (ID), Universitas Pelita Bangsa
Openalex Percentile: Top 79%
Spam and Phishing Detection
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.