Abstract
This study provides an insightful analysis of Peruvian political approval rating sentiment, using Twitter data and applying various ranking algorithms. Despite the challenging context of political instability, the research achieved a high degree of accuracy, with Linear SVC classification leading the way. The detailed breakdown of the results and the evident correlation between tweet sentiment and real-world events provide compelling validation of the chosen methods. The authors’ exploration of various machine learning techniques amplifies the relevance of the study. The research collected 8274 tweets from the @presidenciaperu account, employing API v2 during the month of April 2023, regarding the government’s political approval rating, with the objective of identifying the accuracy of Machine Learning algorithms NB multinomial, NB Bernoulli, Support Vector linear classifier, Logistic regression classifier and KNeighbors classifier from the sentiment analysis of Tweets in Spanish language. Tweets were processed using PLN, words were vectorized with the bag of words algorithm, allowing to build a vocabulary of 5773 tweets with negative (0) and positive (1) polarity in tweets with the support of Python and BETO. Five machine learning sentiment analysis techniques were compared, resulting in an accuracy of 96.3636% (F1Score = 0.98) for the linear SVC, an accuracy of 95.3246% (F1Score = 0.98) for the KNeighbors classifier, an accuracy of 95.2380% (F1Score = 0.98) for the logistic regression classifier, and a tie in accuracy of 94.8051% for NB multinomial and NB Bernoulli. The results indicate that the optimal algorithm was the Support Vector linear classifier with 96.3636% accuracy applied in a Peruvian political approval index environment.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
References
Navarro, L.F.S.: Peruvian president’s approval rating based on sentiment analysis on tweet data. TECHNO Rev. Int. Technol. Sci. Soc. Rev. Revista Internacional de Tecnología, Ciencia y Sociedad 11 (2022). https://doi.org/10.37467/REVTECHNO.V11.4396
Yauri, J., Solis, L., Porras, E., Lagos, M., Tinoco, E.: Approval rating of peruvian politicians and policies using sentiment analysis on Twitter. Int. J. Adv. Comput. Sci. Appl. 13(6), 812–818 (2022). https://doi.org/10.14569/IJACSA.2022.0130696
Ipsos | Investigación de Mercados. https://www.ipsos.com/es-pe. Accessed 16 June 2023
CPI - compañia peruana de estudios de mercado y opinión pública sac. https://cpi.pe/index.html. Accessed 16 June 2023
IEP | Instituto de Estudios PeruanosInstituto de Estudios Peruanos. https://iep.org.pe/. Accessed 16 June 2023
Desaprobación del Congreso: el 91% de los peruanos reprueban gestión de los parlamentarios | Actualidad | La República. https://larepublica.pe/politica/actualidad/2023/06/25/iep-el-91-de-los-peruanos-desaprueba-al-congreso-dina-boluarte-poder-ejecutivo-2276450. Accessed 26 June 2023
IEP: Base enero II 2023: total de entrevistados-Nacional (1214) Base enero II 2023: total de entrevistados-Nacional, 1214. https://iep.org.pe/wp-content/uploads/2023/01/Informe-IEP-OP-Enero-II-2023-completo-v2.pdf. Accessed 15 June 2023
El Peruano - Resolución del Congreso que declara la permanente incapacidad moral del Presidente de la República y la vacancia de la Presidencia de la República - RESOLUCION – 001-2022-2023-CR - PODER LEGISLATIVO - CONGRESO DE LA REPUBLICA. https://busquedas.elperuano.pe/normaslegales/resolucion-del-congreso-que-declara-la-permanente-incapacida-resolucion-001-2022-2023-cr-2132939-1/. Accessed 6 July 2023
Paro nacional: un recuento de lo que se vivió desde las manifestaciones en la Toma de Lima del 19 de enero. https://data.larepublica.pe/paro-nacional-un-recuento-de-lo-que-se-vivio-en-las-manifestaciones-de-la-denominada-toma-de-lima-del-19-de-enero/. Accessed 6 July 2023
IPSOS: Encuesta Nacional Urbana-Rural. https://www.ipsos.com/sites/default/files/ct/news/documents/2023-01/Informe%20Encuesta%20Nacional%20Urbano%20Rural%20-%20Perú%2021%20al%2013%20de%20enero%202023_0.pdf. Accessed 8 July 2023
Gómez-Torres, E., et al.: Influencia de redes sociales en el análisis de sentimiento aplicado a la situación política en Ecuador. Enfoque UTE 9(1), 67–78 (2018). https://doi.org/10.29019/ENFOQUEUTE.V9N1.235
Digital 2022: Peru — DataReportal – Global Digital Insights. https://datareportal.com/reports/digital-2022-peru. Accessed 28 June 2023
Orantes Rivera, E.T.: El dispositivo de la propaganda en las redes sociales de la campaña presidencial de El Salvador (2018–2019). Comunicación y Medios 30(43), 62 (2021). https://doi.org/10.5354/0719-1529.2021.58774
Lu, Y., et al.: Pattern recognition and artificial intelligence (2020). https://link.springer.com/book/10.1007/978-3-030-59830-3. Accessed 30 June 2023
Martínez-Cámara, E., Martín-Valdivia, M.T., Ureña-López, L.A., Montejo-Ráez, A.R.: Sentiment analysis in Twitter. Nat. Lang. Eng. 20(1), 1–28 (2014). https://doi.org/10.1017/S1351324912000332
Linares, R., Herrera, J., Cuadros, A., Alfaro, L.: Prediction of tourist traffic to Peru by using sentiment analysis in Twitter social network. In: Proceedings - 2015 41st Latin American Computing Conference, CLEI 2015 (2015). https://doi.org/10.1109/CLEI.2015.7360051
AminiMotlagh, M., Shahhoseini, H.S., Fatehi, N.: A reliable sentiment analysis for classification of tweets in social networks. Soc. Netw. Anal. Min. 13(1) (2023). https://doi.org/10.1007/s13278-022-00998-2
Soria, J.J., De la Cruz, G., Molina, T., Ramos-Sandoval, R.: Comparative approach of sentiment analysis algorithms to classify social media information gathering in the Spanish language. In Silhavy, R., Silhavy, P., Prokopova, Z. (eds.) Data Science and Algorithms in Systems. CoMeSySo 2022. LNNS, vol. 597, pp. 762–773. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-21438-7_64
Dina Boluarte: Presidenta desactiva su cuenta oficial de Twitter, pero mantiene su perfil en Facebook adelanto de elecciones protestas en Lima protestas en el Perú | POLITICA | EL COMERCIO PERÚ. https://elcomercio.pe/politica/actualidad/dina-boluarte-presidenta-desactiva-su-cuenta-oficial-de-twitter-pero-mantiene-su-perfil-en-facebook-adelanto-de-elecciones-protestas-en-lima-protestas-en-el-peru-noticia/. Accessed 9 July 2023
Limaylla-Lunarejo, M.I., Condori-Fernandez, N., Luaces, M.R.: Requirements classification using FastText and BETO in Spanish documents. In: Ferrari, A., Penzenstadler, B. (eds.) Requirements Engineering: Foundation for Software Quality. REFSQ 2023. LNCS, vol. 13975, pp. 159–176. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-29786-1_11/COVER
finiteautomata/beto-sentiment-analysis · Hugging Face. https://huggingface.co/finiteautomata/beto-sentiment-analysis. Accessed 23 June 2023
Pérez, J.M., Giudici, J.C., Luque, F.: pysentimiento: a Python toolkit for sentiment analysis and SocialNLP tasks, June 2021. https://arxiv.org/abs/2106.09462v1. Accessed 9 July 2023
Cañete, J., Chaperon, G., Fuentes, R., Jorge, P.: Spanish pre-trained BERT model and evaluation data. In: PML4DC at ICLR, vol. 2020, pp. 1–10 (2020)
Christopher, M.: An Introduction to Information Retrieval, vol. 38, no. c (2009). https://doi.org/10.1210/endo-38-3-156
Montesinos, L.: Análisis de sentimientos y predicción de eventos en Twitter. Santiago De Chile, 12–16 (2014)
Chen, W., Xu, H., Jia, L., Gao, Y.: Machine learning model for Bitcoin exchange rate prediction using economic and technology determinants. Int. J. Forecast. 37(1), 28–43 (2021). https://doi.org/10.1016/j.ijforecast.2020.02.008
Pauli, P.: Análisis de sentimiento: comparación de algoritmos predictivos y métodos utilizando un lexicon español. Instituto tecnológico de Buenos Aires - ITBA, Buenos Aires (2019). http://ri.itba.edu.ar/handle/123456789/1782. Accessed 4 June 2023
Tutor, S.: Autora: Desirée García Soriano Tutor: Rubén Martín Clemente (2021)
Pedersen, R., Schoeberl, M.: An embedded support vector machine. In: Proceedings of the Fourth Workshop on Intelligent Solutions in Embedded Systems, WISES 2006, pp. 79–89 (2006). https://doi.org/10.1109/WISES.2006.237155
Daniel, J., Martin, J.H.: Chapter 5 - Speech and Language Processing (2023)
Ananthakumar, U., Sarkar, R.: Application of logistic regression in assessing stock performances. In: Proceedings - 2017 IEEE 15th International Conference on Dependable, Autonomic and Secure Computing, 2017 IEEE 15th International Conference on Pervasive Intelligence and Computing, 2017 IEEE 3rd International Conference on Big Data Intelligence and Compu, vol. 2018, pp. 1242–1247 (2018). https://doi.org/10.1109/DASC-PICom-DataCom-CyberSciTec.2017.199
Lin, S.Y., Kung, Y.C., Leu, F.Y.: Predictive intelligence in harmful news identification by BERT-based ensemble learning model with text sentiment analysis. Inf. Process Manag. 59(2) (2022). https://doi.org/10.1016/j.ipm.2022.102872
Uddin, S., Haque, I., Lu, H., Moni, M.A., Gide, E.: Comparative performance analysis of K-nearest neighbour (KNN) algorithm and its different variants for disease prediction. Sci. Rep. 12(1) (2022). https://doi.org/10.1038/s41598-022-10358-x
Rodríguez-Ibánez, M., Casánez-Ventura, A., Castejón-Mateos, F., Cuenca-Jiménez, P.M.: A review on sentiment analysis from social media platforms. Exp. Syst. Appl. 223, 119862 (2023). https://doi.org/10.1016/j.eswa.2023.119862
Charpentier, A.: Computational Actuaril Science with R. Taylor & Francis Group, Canada (2015)
Liu, B.: Sentiment analysis: mining opinions, sentiments, and emotions (2015). https://doi.org/10.1017/CBO9781139084789
Russell, M.A.: Mining the Social Web: Analyzing Data from Facebook (2019)
Arango Pastrana, C.A., Osorio Andrade, C.F.: Aislamiento social obligatorio: un análisis de sentimientos mediante machine learning. Suma de Negocios 12(26), 1–13 (2021). https://doi.org/10.14349/sumneg/2021.v12.n26.a1
Liu, B.: Document sentiment classification. In: Sentiment Analysis and Opinion Mining. Lectures on Human Languaje Technologies. Springer, Cham (2012). https://doi.org/10.1007/978-3-031-02145-9_3
Chaibi, M., Benghoulam, E.L.M., Tarik, L., Berrada, M., El Hmaidi, A.: An interpretable machine learning model for daily global solar radiation prediction. Energies (Basel) 14(21) (2021). https://doi.org/10.3390/en14217367
Jurafsky, D., Martin, J.: Naive Bayes and sentiment classification. In: Speech and Language Processing, p. 1024 (2019)
Liu, B.: Sentiment Analysis Mining Opinions, Sentiments, and Emotions, vol. 2 (2011)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
Cite this paper
Abal, R.L., Soria, J.J., Peña, L.S. (2024). Twitter Sentiment Analysis with Machine Learning for Political Approval Rating. In: Silhavy, R., Silhavy, P. (eds) Software Engineering Methods in Systems and Network Systems. CoMeSySo 2023. Lecture Notes in Networks and Systems, vol 909. Springer, Cham. https://doi.org/10.1007/978-3-031-53549-9_37
Download citation
DOI: https://doi.org/10.1007/978-3-031-53549-9_37
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-53548-2
Online ISBN: 978-3-031-53549-9
eBook Packages: Intelligent Technologies and RoboticsIntelligent Technologies and Robotics (R0)