Twitter Sentiment Analysis Regarding the Influence of Political Figures Using the Distance – Weighted K – Nearest Neighbor Method
Keywords:
sentiment analysis, twitter, political figures, distance weighted k-nearest neighbor, k-nearest neighborAbstract
Social media such as Twitter has become an important platform for voicing public opinion, including in the political context. This study aims to classify public sentiment towards political figures on Twitter using the K – Nearest Neighbor (KNN) algorithm and its development, Distance – Weighted K – Nearest Neighbor (DWKNN). KNN is a nearest neighbor – based classification algorithm, but its performance is greatly influenced by the selection of the k value and does not consider the weight of the distance between neighbors. To overcome these limitations, DWKNN is applied by giving weights based on the distance of each neighbor to the test data. This study goes through the stages of data collection, data preprocessing, feature extraction, cross validation, algorithm implementation, and evaluation using three data balancing scenarios, namely baseline, oversampling, and undersampling. The evaluation results show that DWKNN provides the best performance in the baseline scenario with an accuracy of 68%, precision 52%, recall 47%, and F1 – score 48%, compared to KNN with an accuracy of 66%, precision 47%, recall 45%, and F1 – score 45%. These findings indicate that DWKNN is more effective in classifying public sentiment towards political figures than KNN.