Arvanida Feizal Permana
National Chin Yi University of Technology

Published : 1 Documents Claim Missing Document
Claim Missing Document
Check
Articles

Found 1 Documents
Search

Hate Speech Detection on X Using K-Nearest Neighbor with TF–IDF and Cosine Similarity: Deteksi Ujaran Kebencian pada X Menggunakan K-Nearest Neighbor dengan TF–IDF dan Kesamaan Kosinus Faiq Madani; Arvanida Feizal Permana; Abdul Karim; Riyagung Nuryusufa Tranggono Adi Prasetya; Wendy Sarasjati
Journal of Data Insights Vol 4 No 1 (2026): Journal of Data Insights
Publisher : Department of Sains Data UNIMUS Universitas Muhammadiyah Semarang

Show Abstract | Download Original | Original Source | Check in Google Scholar | DOI: 10.26714/jodi.v4i1.1149

Abstract

The rapid growth of social media has increased online interactions but has also accelerated the spread of hate speech content that may negatively impact individuals and communities. X (formerly Twitter), as one of the largest social networking platforms, enables users to share opinions publicly, making automatic hate speech detection increasingly important. This research proposes a hate speech classification approach using the K-Nearest Neighbor (KNN) algorithm combined with Term Frequency–Inverse Document Frequency (TF–IDF) weighting and Cosine Similarity. The dataset consists of 900 social media posts collected through the platform API and manually labeled into hate speech and non-hate speech categories, consisting of 675 training data and 225 testing data. Prior to classification, text preprocessing techniques including tokenization, stopword removal, and stemming were applied to improve text quality. Model evaluation was conducted using 10-fold cross validation to assess classification performance. Experimental results showed that the KNN algorithm with Cosine Similarity distance measurement and K=3 parameter achieved an accuracy of 78.22% in hate speech detection tasks. The findings indicate that KNN combined with TF–IDF and Cosine Similarity provides a reliable approach for social media text classification and can support automated hate speech detection systems.