Perbandingan Algoritma Naïve Bayes dan KNN pada Analisis Sentimen Kepuasan Pelanggan E-Commerce
DOI:
https://doi.org/10.33050/cerita.v12i2.4434Keywords:
Sentiment Analysis, Naïve Bayes, K-Nearest Neighbor (KNN), E-Commerce, TF-IDF, Customer SatisfactionAbstract
The rapid growth of e-commerce in Indonesia has led to a significant increase in customer reviews on digital platforms. Customer reviews serve as an important source of information for companies to understand customer satisfaction regarding products and services. However, the large volume of review data and the characteristics of unstructured text make manual evaluation inefficient and prone to subjectivity. Therefore, a machine learning-based approach is required to automatically classify sentiments. This study aims to compare the performance of Naïve Bayes and K-Nearest Neighbor (KNN) algorithms in sentiment analysis of customer satisfaction in e-commerce at PT XYZ. The dataset consisted of 3,500 customer reviews, divided into 80% training data (2,800 data) and 20% testing data (700 data). The research stages included text preprocessing consisting of case folding, cleaning, tokenization, stopword removal, and stemming, followed by feature weighting using the Term Frequency–Inverse Document Frequency (TF-IDF) method. The classification process was performed using Naïve Bayes and KNN algorithms with a parameter of K = 5. Model evaluation was conducted using accuracy, precision, recall, and F1-score metrics. The results indicate that the KNN algorithm achieved the best performance compared to Naïve Bayes, with an accuracy of 92.57%, precision of 91.56%, recall of 92.73%, and F1-score of 92.14%, while Naïve Bayes achieved an accuracy of 86.85%, precision of 86.30%, recall of 88.50%, and F1-score of 87.30%. Therefore, the KNN algorithm is considered more effective in classifying customer satisfaction sentiment on PT XYZ e-commerce review data. The findings of this study are expected to assist companies in understanding customer perceptions more efficiently and support service quality improvement through data-driven decision-making