Main Article Content


Many cutting-edge language models have been used in the past to forecast election results. Sentiment analysis aids in opinion mining – a common experiment used to detect public opinions – on a given topic. Twitter has gained popularity and established itself as a crucial instrument for analyzing public opinion on elections and other trending issues. The unexpected but interesting results of recently held Nigeria's presidential election shifted attention to the upcoming governorship race in Lagos State. In this work, we propose a Google’s Bidirectional Encoder Representations from Transformers (BERT) model for the sentiment analysis of governorship election in Lagos State, Nigeria, using Twitter data. A total of 800,000 personal and public tweets were scraped from twitter concerning the three prominent contesting Lagos State Gubernatorial candidates using carefully selected search queries. The tweets were preprocessed to avoid noise and inconsistencies and the preprocessed tweets were parsed into the pre-trained and finetuned BERT model. The result was analyzed to establish the sentiments of the public about the candidates. The social networks of the candidates were also presented and the effect of parameter using different learning rates (LR) was also considered. The BERT model achieved the maximum performance under varied learning rate and epoch sizes of 88% precision, 92% recall and 91% F1-Measure. Results also showed that the learning rate at 1e-7 gave the best performance. Also, the smaller the learning rate, the higher the accuracy but the larger the epoch size, the higher the accuracy. Applying the developed BERT model to the public’s tweet showed that the election will be a two-party race between the Labour Party and All Progressives Congress party, thereby challenging the status quo. The results of the experiment demonstrated that sentiment analysis and other Natural Language Processing activities can help with comprehension of the social media environment. Results also showed how much influence each candidate has over the outcome of the election. We come to the conclusion that estimating election results and providing insights for electoral parties can benefit from sentiment analysis and other language models.


NLP NLU Twitter sentiment analysis opinion mining Nigeria election machine learning BERT LSTM SVM

Article Details

How to Cite
Olabanjo, O., Wusu, A., Padonu, R., AFISI, O., & Mazzara, M. (2023). Twitter Sentiment Analysis of Lagos State 2023 Gubernatorial Election Using BERT. Journal of Advanced Research in Social Sciences, 6(2), 59–75.