This study aims to develop an optimized machine learning-based sentiment classification model for election-related issues. A dataset comprising 10,001 entries was collected from the social media platform X and manually labeled into three sentiment classes: positive, negative, and neutral. The preprocessing stage involved text cleaning, stemming, and feature transformation using the Term Frequency-Inverse Document Frequency (TF-IDF) method. To address class imbalance, the Synthetic Minority Over-sampling Technique (SMOTE) was employed. Three baseline classification algorithms—K-Nearest Neighbors (KNN), Support Vector Machine (SVM), and Gaussian Naive Bayes (GNB)—were initially evaluated to establish a performance benchmark. Model development proceeded by applying hyperparameter optimization using the Optuna framework and further enhancing the models via boosting with Extreme Gradient Boosting (XGBoost). Experimental results revealed that the combination of SVM with Optuna and XGBoost achieved the best performance, reaching 97% accuracy, precision, recall, and F1-score across all classes. In contrast, the KNN and GNB models experienced a notable decline in performance following hyperparameter tuning, although partial recovery was observed when combined with boosting. These findings suggest that hyperparameter tuning and boosting are not universally effective across all classifiers, yet their synergistic application significantly enhances performance in SVM-based models. This study highlights the importance of model-specific optimization strategies in building robust sentiment analysis systems, particularly for handling unbalanced public opinion data in social media contexts.
Copyrights © 2025