This study highlights the importance of selecting appropriate algorithms for text data analysis and provides recommendations for future exploration of other machine learning and deep learning models to improve the accuracy of sentiment analysis. This research compares the accuracy level of the K-Nearest Neighbor (KNN) and Naïve Bayes algorithms in sentiment analysis in the 2024 Central Java gubernatorial election using data from the social media platform X (formerly Twitter). The data consists of 1,337 posts classified as positive or negative sentiment. Data crawling was done using RapidMiner, and analysis was done via Python in Google Colab. The research results show that the KNN algorithm achieves the highest accuracy of 81%, while Naïve Bayes has a maximum accuracy of 79%. The KNN algorithm is superior in handling text data because of the dependent calculations between attributes, while Naïve Bayes which uses independent calculations has slightly lower performance. This research provides insight into the reaction of public sentiment towards the candidate for governor of Central Java, where the Andhika-Hendi pair received more positive sentiment than Lutfi-Yasin
                        
                        
                        
                        
                            
                                Copyrights © 2025