A Hybrid Transformer-Ensemble Framework for Precise Election Poll Analysis
Abstract
1. Introduction
- House effects and pollster bias:
- Time-varying electorate and late-stage momentum shifts:
- Sparse and irregular polling intervals:
- Heterogeneous covariates:
- Target ambiguity and calibration challenges:
- Distribution shifts across election types:
- Modeling heterogeneous and temporally evolving polling data:
- Enhancing robustness against polling noise and systematic bias:
- Providing transparent component-level performance analysis:
2. Literature Review
2.1. Election Polling Models: Traditional Approaches
2.2. Deep Learning Approaches in Election Prediction
2.3. Transformer Models and Their Application in Election Forecasting
2.4. Ensemble Learning Techniques in Election Prediction
2.5. Hybrid Approaches: Transformer Ensemble Learning
2.6. Challenges in Election Prediction Models
2.7. Summary and Positioning of the Present Study
3. Dataset Description
4. Proposed Methodology
4.1. Data Preprocessing
4.1.1. Data Cleaning and Transformation
4.1.2. Text Preprocessing
- Tokenization: A text, , is split into tokens, .
- Stop Word Removal: A stop word list, , is used to filter out common words that do not contribute to the analysis. The resulting set of words, , is given by Equation (2).
- TF-IDF Vectorization: For each term, , in the document set, , the term frequency (TF) and inverse document frequency (IDF) are computed as in Equations (3) and (4), respectively.
4.1.3. Feature Engineering
4.2. Model Design
4.2.1. Transformer Model for Sequence Learning
4.2.2. Transformer Input Representation and Temporal Serialization
4.2.3. Ensemble Learning for Robust Predictions
4.3. Model Training and Evaluation
4.3.1. Training the Model
4.3.2. Hyperparameter Tuning
4.3.3. Evaluation Metrics
4.4. Hybrid Approach Integration
5. Experimental Setup
6. Results and Discussion
6.1. Performance of Individual Models
6.2. Ensemble Component Contribution Analysis
6.3. Ablation Study Results
6.4. Statistical Significance of the Results
- p-value: all p-values are below 0.05, confirming that the differences observed are statistically significant.
- We computed the 95% confidence intervals (CI) for the difference in performance metrics, which gives an estimate of the range within which true differences lie.
- These intervals indicate that the improvements in accuracy, precision, recall, and AUC-ROC are consistent and reliable.
- Cohen’s d values for the performance differences quantify the magnitude of the improvements between the base paper and the proposed model. A Cohen’s d greater than 0.5 indicates a moderate effect, while values > 0.8 represent a dramatic effect.
- These results indicate that the observed improvements are not only statistically significant but also practically meaningful, particularly for accuracy and confidence calibration.
6.5. Baseline Temporal Models
7. Limitations and Future Work
7.1. Limitations
7.2. Future Work
8. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Gao, M.; Wang, Z.; Wang, K.; Liu, C.; Tang, S. Forecasting elections with agent-based modeling: Two live experiments. PLoS ONE 2022, 17, e0270194. [Google Scholar] [CrossRef]
- Koli, A.M.; Ahmed, M. Machine Learning based Parametric Estimation Approach for poll prediction. Recent Adv. Comput. Sci. Commun. 2019, 14, 1287–1299. [Google Scholar] [CrossRef]
- Lewis-Beck, M.S.; Stegmaier, M. Citizen forecasting: Can UK voters see the future? Elect. Stud. 2010, 30, 264–268. [Google Scholar] [CrossRef]
- Lewis-Beck, M.S. Election Forecasting: Principles and practice. Br. J. Politics Int. Relat. 2005, 7, 145–164. [Google Scholar] [CrossRef]
- Baskakova, Y.; Terentyeva, N. Gallup’s Likely Voter Model: Evolution and modifications. Monit. Obŝestven. Mneniâ Èkon. I Soc. Peremeny 2018, 4, 25–38. [Google Scholar] [CrossRef]
- Topîrceanu, A. Macro-Scale Temporal Attenuation for Electoral Forecasting: A Retrospective Study on recent elections. Mathematics 2025, 13, 604. [Google Scholar] [CrossRef]
- Topîrceanu, A.; Precup, R.-E. A framework for improving electoral forecasting based on time-aware polling. Soc. Netw. Anal. Min. 2020, 10, 39. [Google Scholar] [CrossRef]
- Puspanath, S.; Ramesh, S.; Muthusamy, N.; Pandian, S.P. Neural democracy prognosticator: Rise of AI for accurate electoral projection. AIP Conf. Proc. 2025, 3279, 020007. [Google Scholar] [CrossRef]
- Stegmaier, M.; Jokinsky, S.; Lewis-Beck, M.S. The evolution of election forecasting models in the UK. Elect. Stud. 2023, 86, 102694. [Google Scholar] [CrossRef]
- Lewis-Beck, M.S.; Stegmaier, M. Election Forecasting: Scientific Approaches. In Encyclopedia of Social Network Analysis and Mining; Springer: Berlin/Heidelberg, Germany, 2018; pp. 742–749. [Google Scholar] [CrossRef]
- Mongrain, P.; Stegmaier, M. Introduction to forecasting the 2024 US elections. PS Political Sci. Politics 2024, 58, 184–191. [Google Scholar] [CrossRef]
- Thomas, M.; Sopata, C.; Rogers, B.; Marusco, S. Forecasting the 2020 Presidential Election: A Comparison of Methods. In 2021 Systems and Information Engineering Design Symposium (SIEDS); IEEE: New York, NY, USA, 2021; pp. 1–5. [Google Scholar] [CrossRef]
- Oletsky, O.; Peleshko, D.; Moholivskyi, V. Modeling Changes of Opinions as Transition Probabilities Within One- and Two-Level Model “State-Probability of Action”; CEUR: Geneva, Switzerland, 2025; p. 7. [Google Scholar]
- Liu, R.; Yao, X.; Guo, C.; Wei, X. Can we forecast presidential election using Twitter Data? An integrative modelling approach. Ann. GIS 2020, 27, 43–56. [Google Scholar] [CrossRef]
- Khan, A.; Zhang, H.; Boudjellal, N.; Ahmad, A.; Shang, J.; Dai, L.; Hayat, B. Election prediction on Twitter: A systematic mapping study. Complexity 2021, 2021, 5565434. [Google Scholar] [CrossRef]
- Asokere, M.; Wusu, A.; Olabanjo, O. Twitter (X) as an electoral barometer: Systematic evidence from sentiment analysis of Twitter data. Int. J. Inf. Technol. 2025. [Google Scholar] [CrossRef]
- Alvi, Q.; Ali, S.F.; Ahmed, S.B.; Khan, N.A.; Javed, M.; Nobanee, H. On the frontiers of Twitter data and sentiment analysis in election prediction: A review. PeerJ Comput. Sci. 2023, 9, e1517. [Google Scholar] [CrossRef] [PubMed]
- Kampotha, P.; Wang, H.; Li, C. Transformer-Based Models for Commodity Trading Price Forecasting. In 2024 7th International Conference on Data Science and Information Technology (DSIT); IEEE: New York, NY, USA, 2024; pp. 1–5. [Google Scholar] [CrossRef]
- Wu, H.; Li, R.; Sheng, G.; Wilson, D. D-Transformer: A Deep Learning Model for Time Series Prediction. In 2023 Asia-Pacific Conference on Image Processing, Electronics and Computers (IPEC); IEEE: New York, NY, USA, 2023; Volume 81, pp. 313–316. [Google Scholar] [CrossRef]
- Joseph, S.; Jo, A.A.; Raj, E.D. Improving Time Series Forecasting Accuracy with Transformers: A Comprehensive Analysis with Explainability. In 2024 Third International Conference on Electrical, Electronics, Information and Communication Technologies (ICEEICT); IEEE: New York, NY, USA, 2024; pp. 1–7. [Google Scholar] [CrossRef]
- Ughi, R.; Lomurno, E.; Matteucci, M. Two Steps Forward and One Behind: Rethinking Time Series Forecasting with Deep Learning. In International Conference on Machine Learning, Optimization, and Data Science; Lecture Notes in Computer Science; Springer Nature: Cham, Switzerland, 2024; pp. 463–478. [Google Scholar] [CrossRef]
- Cheng, Y.; Li, R.; Cheng, J.; Kong, M. RKTrans: Transformer with Improved Residual Connection Units for Power Forecasting. In 2024 2nd International Conference on Pattern Recognition, Machine Vision and Intelligent Algorithms (PRMVIA); IEEE: New York, NY, USA, 2024; Volume 34, pp. 54–58. [Google Scholar] [CrossRef]
- Lewis-Beck, M.S.; Dassonneville, R. Comparative election forecasting: Further insights from synthetic models. Elect. Stud. 2015, 39, 275–283. [Google Scholar] [CrossRef]
- Lewis-Beck, M.S.; Dassonneville, R. Forecasting elections in Europe: Synthetic models. Res. Politics 2015, 2, 2053168014565128. [Google Scholar] [CrossRef]
- Montalvo, J.G.; Papaspiliopoulos, O.; Stumpf-Fétizon, T. Bayesian forecasting of electoral outcomes with new parties’ competition. Eur. J. Political Econ. 2019, 59, 52–70. [Google Scholar] [CrossRef]
- Camatarri, S. Predicting popular-vote shares in US presidential elections: A model-based strategy relying on ANES data. PS Political Sci. Politics 2024, 58, 253–257. [Google Scholar] [CrossRef]
- Midilli, Y.E.; Parshutin, S. A Review for Pre-Trained Transformer-Based Time Series Forecasting Models. In 2023 IEEE 64th International Scientific Conference on Information Technology and Management Science of Riga Technical University (ITMS); IEEE: New York, NY, USA, 2023; pp. 1–8. [Google Scholar] [CrossRef]
- Bharti, M.K.; Wadhvani, R.; Gyanchandani, M.; Gupta, M. Transformer-Based Multivariate Time Series Forecasting. In 2024 IEEE International Students’ Conference on Electrical, Electronics and Computer Science (SCEECS); IEEE: New York, NY, USA, 2024; pp. 1–6. [Google Scholar] [CrossRef]
- Yu, H. Comparative analysis of LSTM and transformer-based models for stock price forecasting. AIP Conf. Proc. 2024, 3194, 030006. [Google Scholar] [CrossRef]
- Lockerbie, B. The Challenge of Forecasting the 2024 Presidential and House Elections: Economic Pessimism and Election Outcomes. PS Political Sci. Politics 2024, 58, 244–247. [Google Scholar] [CrossRef]
- Thakur, G.; Chouksey, P.; Chopra, M.; Sadotra, P. Fortifying E-Voting Systems: Integrating Visual Cryptography with ECC and ChaCha20-Poly1305 for Enhanced Security. J. Commun. Softw. Syst. 2025, 21, 427–435. [Google Scholar] [CrossRef]
- Election Polls DataSets. Available online: https://www.kaggle.com/datasets/gmkeshav/election-polls-datasets (accessed on 29 October 2025).





| Column Name | Description | Example Values |
|---|---|---|
| question_id | Unique identifier for each poll question | 148,863, 77,170 |
| poll_id | Identifier for the specific poll | 8990, 9000 |
| cycle | Election cycle (year) | 2020, 2022 |
| state | State in which the poll was conducted | California, Georgia |
| pollster_id | Unique identifier for the polling agency | 568, 1302 |
| pollster | Name of the polling agency | YouGov, Morning Consult |
| sponsor_ids | Identifier for the sponsor(s) of the poll | 352, 538 |
| sponsors | Organization or entity sponsoring the poll | Economist, Politico |
| display_name | Name displayed for the pollster or polling organization | YouGov, Morning Consult |
| pollster_rating_id | Rating identifier for the pollster | 391, 218 |
| pollster_rating_name | Rating assigned to the pollster | B+, B |
| fte_grade | Pollster’s grade based on their accuracy and reliability | B+, A− |
| sample_size | Number of respondents in the poll | 1303, 2000 |
| population | Type of population sampled (e.g., registered voters, likely voters) | rv (registered voters), lv (likely voters) |
| methodology | Method of polling (e.g., online, live phone) | Online, live phone |
| office_type | Type of election office being polled (e.g., U.S. House, Governor) | U.S. House, U.S. Senate |
| seat_number | Electoral seat or district number | 10, 35 |
| start_date | Date when the poll started | 10/30/2021, 10/29/2021 |
| end_date | Date when the poll ended | 11/02/2021, 11/01/2021 |
| sponsor_candidate | Political candidate or party sponsoring the poll | Democratic party, Republican party |
| tracking | Whether the poll is tracking trends over time | TRUE, FALSE |
| nationwide_batch | Whether the poll is a nationwide poll | TRUE, FALSE |
| created_at | Timestamp of when the poll data was recorded or created | 11/03/2021 09:37, 11/02/2021 09:36 |
| notes | Additional notes related to the poll | N/A, Tracking data not available |
| stage | Election stage (e.g., general election, primary election) | general, runoff |
| race_id | Unique identifier for the election race | 8990, 8989 |
| candidate_id | Unique identifier for the candidate being polled | 21,377, 14,567 |
| candidate_name | Name of the political candidate | Terry R. McAuliffe, Jon Ossoff |
| candidate_party | Political party of the candidate | DEM, REP, OTH |
| pct | Percentage of votes support for the candidate | 47.0, 50.8 |
| Component | Specification |
|---|---|
| Dataset | Election polls data (structured + unstructured) |
| Data Source | YouGov, Morning Consult, Harris Insights, etc. |
| Data Preprocessing | - Impute missing values (mean for continuous, mode for categorical) - One-hot encoding for categorical variables - Tokenization and stop word removal for text data - Text vectorization (TF-IDF or BERT embeddings) |
| Computational Environment | Programming Language: Python 3.8 Libraries: TensorFlow, Keras, Scikit-learn, XGBoost, LightGBM, CatBoost Hardware: NVIDIA Tesla P100 GPU, Intel Xeon CPU RAM: 64 GB IDE: Jupyter Notebook 6.5.4, Visual Studio Code 1.85.0 OS: Ubuntu 20.04 LTS |
| Model Architecture | Transformer model: embedding, self-attention, multi-head attention, feed-forward; Neural network ensemble models: Random Forest, Gradient Boosting, XGBoost, LightGBM, stacking, Voting |
| Training | Data Split: 80% training, 20% testing Optimizer: Adam (for Transformer), gradient descent for ensemble methods Hyperparameter Tuning: grid search/random search |
| Evaluation Metrics | Accuracy, F1-Score, Mean Absolute Error (MAE), AUC-ROC Statistical Parameters: |
| Hyperparameter Tuning | Transformer: number of layers, attention heads, learning rate, batch size Random Forest: number of trees, max depth, min samples split Gradient Boosting: learning rate, number of estimators, max depth XGBoost: learning rate, max depth, subsample rate LightGBM: learning rate, max depth, min child samples Stacking: base models, meta-learner type Voting: Bbse models (Random Forest, XGBoost, etc.) |
| Ablation Study | - Transformer-only: evaluate Transformer model in isolation for feature extraction. - Ensemble-only: evaluate ensemble models (e.g., Random Forest, XGBoost, etc.) in isolation. - Transformer–ensemble: evaluate combined Transformer and ensemble methods for final predictions. - Transformer–stacking: evaluate performance improvement with stacking. - Transformer–voting: evaluate performance improvement with voting models. |
| Training Process | Train Transformer and ensemble models using backpropagation, cross-validation, and hyperparameter optimization |
| Model | Accuracy (%) | F1-Score | Precision | Recall | AUC-ROC | MAE |
|---|---|---|---|---|---|---|
| Transformer | 86.8 | 0.84 | 0.86 | 0.82 | 0.93 | 0.21 |
| Random Forest | 81.6 | 0.79 | 0.81 | 0.77 | 0.89 | 0.27 |
| XGBoost | 84.5 | 0.81 | 0.83 | 0.79 | 0.91 | 0.23 |
| Gradient Boosting | 83.2 | 0.8 | 0.82 | 0.78 | 0.9 | 0.25 |
| LightGBM | 85.3 | 0.82 | 0.84 | 0.8 | 0.92 | 0.24 |
| Voting | 83.9 | 0.8 | 0.82 | 0.79 | 0.9 | 0.26 |
| Ensemble Variant | Accuracy (%) | AUC-ROC | F1-Score | ΔAccuracy vs. Full | ΔAUC vs. Full |
|---|---|---|---|---|---|
| Full (RF + XGB + GB + LGBM) | 93.4 | 0.94 | 0.88 | — | — |
| Full − RF | 92.7 | 0.938 | 0.875 | −0.7 | −0.002 |
| Full − XGBoost | 91.9 | 0.93 | 0.868 | −1.5 | −0.010 |
| Full − Gradient Boosting | 92.4 | 0.935 | 0.872 | −1.0 | −0.005 |
| Full − LightGBM | 92.1 | 0.932 | 0.87 | −1.3 | −0.008 |
| Model | Accuracy (%) | F1-Score | Precision | Recall | AUC-ROC | MAE | Training Time (s) |
|---|---|---|---|---|---|---|---|
| Transformer-only | 86.8 | 0.84 | 0.86 | 0.82 | 0.93 | 0.21 | 210 |
| Ensemble-only | 82 | 0.8 | 0.82 | 0.78 | 0.9 | 0.26 | 145 |
| Transformer ensemble (proposed) | 93.4 | 0.88 | 0.9 | 0.85 | 0.94 | 0.19 | 295 |
| Metric | Base Paper Mean | Proposed Model Mean | t-Statistic | p-Value | 95% CI for Difference (Lower Bound, Upper Bound) | Effect Size (Cohen’s d) |
|---|---|---|---|---|---|---|
| Accuracy (%) | 92 | 93.4 | 6.67 | 0.0001 | (0.9, 1.8) | 0.75 |
| F1-Score | 0.87 | 0.88 | 2.48 | 0.015 | (0.01, 0.03) | 0.48 |
| Precision | 0.85 | 0.9 | 4.15 | 0.0007 | (0.03, 0.05) | 0.62 |
| Recall | 0.8 | 0.85 | 3.62 | 0.002 | (0.03, 0.05) | 0.56 |
| AUC-ROC | 0.91 | 0.94 | 4.15 | 0.0007 | (0.02, 0.05) | 0.61 |
| MAE | 0.25 | 0.19 | 5.91 | 0.0001 | (0.04, 0.08) | 0.8 |
| Model | Accuracy (%) | F1-Score | Precision | Recall | AUC-ROC |
|---|---|---|---|---|---|
| LSTM | 83.2 | 0.8 | 0.81 | 0.79 | 0.89 |
| GRU | 84.1 | 0.81 | 0.82 | 0.8 | 0.9 |
| Temporal CNN (TCN) | 82.6 | 0.79 | 0.8 | 0.78 | 0.88 |
| Transformer (Standalone) | 86.8 | 0.84 | 0.86 | 0.82 | 0.93 |
| Transformer Ensemble (Proposed) | 93.4 | 0.88 | 0.9 | 0.85 | 0.94 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Roy, D.; Shukla, A.; Akuli, R.K.; Agrawal, A.K.; Bokoro, P.N.; Dubey, P. A Hybrid Transformer-Ensemble Framework for Precise Election Poll Analysis. Computers 2026, 15, 481. https://doi.org/10.3390/computers15080481
Roy D, Shukla A, Akuli RK, Agrawal AK, Bokoro PN, Dubey P. A Hybrid Transformer-Ensemble Framework for Precise Election Poll Analysis. Computers. 2026; 15(8):481. https://doi.org/10.3390/computers15080481
Chicago/Turabian StyleRoy, Dipayan, Abhinav Shukla, Ram Krishna Akuli, Ayush Kumar Agrawal, Pitshou N. Bokoro, and Parul Dubey. 2026. "A Hybrid Transformer-Ensemble Framework for Precise Election Poll Analysis" Computers 15, no. 8: 481. https://doi.org/10.3390/computers15080481
APA StyleRoy, D., Shukla, A., Akuli, R. K., Agrawal, A. K., Bokoro, P. N., & Dubey, P. (2026). A Hybrid Transformer-Ensemble Framework for Precise Election Poll Analysis. Computers, 15(8), 481. https://doi.org/10.3390/computers15080481

