Sentiment Analysis of YouTube Comments Using the K-Nearest Neighbors (KNN) Method from an Axiological Perspective - Lestandy, Merinda; Patmanthara, Syaad (ENERGY: JURNAL ILMIAH ILMU-ILMU TEKNIK, 2025)
The rapid development of social media as a space for digital interaction has increased the need for sentiment analysis to understand public opinion in a systematic and measurable way. This study analyzes YouTube comment sentiment using the K-Nearest Neighbor (K-NN) method while also examining the axiological value of applying this technology in support of a more ethical digital ecosystem. The dataset consists of 8,200 YouTube comments obtained from Kaggle without predefined sentiment labels. The data were preprocessed through case folding, tokenization, stopword removal, stemming, and normalization. Initial sentiment labels were generated automatically using K-Means clustering to form two classes—positive and negative—and were partially verified manually. The labeled data were split into training and testing sets with ratios of 50:50, 60:40, 70:30, and 80:20, and evaluated using K-NN with k values of 3, 5, 7, and 9. Model performance was assessed using a confusion matrix with accuracy, precision, recall, and F1-score metrics. The results show that accuracy ranges from 0.95 to 0.96, with the best performance achieved at a 70:30 split and an optimal k value yielding 0.96 accuracy. Beyond technical contributions, this study highlights the ethical and practical value of sentiment analysis for interpreting public opinion, supporting fairer content moderation, and improving communication quality in social media environments.