Open Access iconOpen Access



From Social Media to Ballot Box: Leveraging Location-Aware Sentiment Analysis for Election Predictions

Asif Khan1, Nada Boudjellal2, Huaping Zhang1,*, Arshad Ahmad3, Maqbool Khan3

1 School of Computer Science and Technology, Beijing Institute of Technology, Beijing, 100081, China
2 The Faculty of New Information and Communication Technologies, University Abdel-Hamid Mehri Constantine 2, Constantine, 25000, Algeria
3 Department of IT and Computer Science, Pak-Austria Fachhochschule: Institute of Applied Sciences and Technology, Haripur, 22620, Pakistan

* Corresponding Author: Huaping Zhang. Email: email

(This article belongs to this Special Issue: Advance Machine Learning for Sentiment Analysis over Various Domains and Applications)

Computers, Materials & Continua 2023, 77(3), 3037-3055.


Predicting election outcomes is a crucial undertaking, and various methods are employed for this purpose, such as traditional opinion polling, and social media analysis. However, traditional polling approaches often struggle to capture the intricate nuances of voter sentiment at local levels, resulting in a limited depth of analysis and understanding. In light of this challenge, this study focuses on predicting elections at the state/regional level along with the country level, intending to offer a comprehensive analysis and deeper insights into the electoral process. To achieve this, the study introduces the Location-Based Election Prediction Model (LEPM), which utilizes social media data, specifically Twitter, and integrates location-aware sentiment analysis techniques at both the state/region and country levels. LEPM predicts the support and opposing strength of each political party/candidate. To determine the location of users/voters who have not disclosed their location information in tweets, the model utilizes a Voter Location Detection (VotLocaDetect) approach, which leverages recent tweets/posts. The sentiment analysis techniques employed in this study include rule-based sentiment analysis, Valence Aware Dictionary and Sentiment Reasoner (VADER) as well as transformers-based sentiment analysis such as Bidirectional Encoder Representations from Transformers (BERT), BERTweet, and Election based BERT (ElecBERT). This study uses the 2020 United States (US) Presidential Election as a case study. By applying the LEPM model to the election, the study demonstrates its ability to accurately predict outcomes in forty-one states, achieving an 0.84 accuracy rate at the state level. Moreover, at the country level, the LEPM model outperforms traditional polling results. With a low Mean Absolute Error (MAE) of 0.87, the model exhibits more precise predictions and serves as a successful alternative to conventional polls and other methodologies. Leveraging the extensive social media data, the LEPM model provides nuanced insights into voter behavior, enabling policymakers to make informed decisions and facilitating in-depth analyses of elections. The study emphasizes the importance of using social media data for reliable election prediction and offers implications for enhancing prediction accuracy and understanding voter sentiment and behavior.


Supplementary Material

Supplementary Material File

Cite This Article

A. Khan, N. Boudjellal, H. Zhang, A. Ahmad and M. Khan, "From social media to ballot box: leveraging location-aware sentiment analysis for election predictions," Computers, Materials & Continua, vol. 77, no.3, pp. 3037–3055, 2023.

cc This work is licensed under a Creative Commons Attribution 4.0 International License , which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
  • 285


  • 159


  • 0


Share Link