The megathrust earthquake in Indonesia is a major potential natural disaster capable of triggering high-magnitude earthquakes and tsunamis, thereby influencing public perception. This study aims to analyze public opinion and identify the main topics related to the megathrust earthquake issue using Bidirectional Encoder Representations from Transformers (BERT) and Robustly Optimized BERT Pretraining Approach (RoBERTa) models. The dataset consists of 16,592 comments collected from the X social media platform during the period 2012–2025, which were classified into three sentiment categories, positive, negative, and neutral. The research methodology included exploratory data analysis, text preprocessing, model training, and evaluation using four experimental scenarios. The results indicate that the best performance was achieved using an 80:10:10 train–validation test split with ten training epochs. The BERT model outperformed RoBERTa, achieving an accuracy of 92,4350%, precision of 92,4291%, recall of 92,4350%, and F1-score of 92,4292%. These findings demonstrate that BERT is more effective in capturing the linguistic context of the Indonesian language. Furthermore, this study contributes to the advancement of artificial intelligence-based sentiment analysis for monitoring public opinion on disaster-related issues and provides a valuable foundation for developing more effective risk communication strategies, disaster mitigation education, and evidence-based policymaking that is more responsive to public perception.
Copyrights © 2026