Social media platforms such as YouTube have become important spaces for the public to express opinions on various policy issues, including the Draft Bill on the Indonesian National Armed Forces (RUU TNI). However, research on sentiment analysis of YouTube comments remains limited, particularly in the application of multi-class classification using the Random Forest algorithm. This study aims to implement Random Forest for classifying sentiments in YouTube comments related to the RUU TNI into three categories: positive, negative, and neutral. The dataset consists of 7118 comments, divided into 5694 training data and 1423 testing data. Sentiment labeling was conducted using a lexicon-based approach, while text representation was carried out using TF-IDF. To address data imbalance, class weighting was applied, and model parameter optimization was performed using the GridSearchCV technique. The optimal parameter combination obtained was n_estimators=300, max_depth=None, max_features='log2', and min_samples_split=20. The evaluation results show that the model with class weighting achieved an accuracy of 80.27%, while the model without weighting achieved 79.42%. These findings indicate that applying class weighting and parameter optimization effectively improves sentiment classification performance of public opinions on the RUU TNI policy on YouTube.
Copyrights © 2025