, Volume 34, Issue 3, pp 589–598 | Cite as

Predicting the ideological orientation during the Spanish 24M elections in Twitter using machine learning

  • Ronaldo Cristiano Prati
  • Elias Said-HungEmail author
Open Forum


Through the application of machine learning techniques, this paper aims to estimate the importance of messages with ideological load during the elections held in Spain on May 24th, 2015 posted by Twitter’s users, as well as other variables associated with the publication of these types of messages. Our study collected and analysed 24,900 tweets associated to two of the main trending topics’ hashtags (#24M and #Elections2015) used in the election day and build a predictive model to infer the ideological orientation for the messages which made use of these hashtags during Election Day. This approach allows us to classify the ideological orientation of all collected tweets, instead of only tweets that explicitly express their ideological or partisan preferences in the messages. Using the ideological orientation for all tweets predicted by our model, it was possible to identify how messages with a defined ideological load were pushed forward by users with leftist tendencies. We also observed a relationship between these messages and the partisan orientation of those who published them.


Social media Political participation Elections Spain Ideology Machine learning 


  1. Anduiza E et al (2013) Mobilization through online social networks: the political protest of the indignados in Spain. Inf Commun Soc. doi: 10.1080/1369118X.2013.808360 Google Scholar
  2. Aragón P et al (2013) Communication dynamics in Twitter during political campaigns: the case of the 2011 Spanish national election. Policy Internet. doi: 10.1002/1944-2866 Google Scholar
  3. Barberá P, Rivero G (2014) Understanding the political representativeness of Twitter Users. Soc Sci Comput Rev. doi: 10.1177/0894439314558836 Google Scholar
  4. Batrinka B, Treleaven PC (2015) Social media analytics: a survey of techniques, tools and platforms. AI Soc. doi: 10.1007/s00146-014-0549-4 Google Scholar
  5. Bird S et al (2009) Natural language processing with Python. O′Reilly Media, BostonzbMATHGoogle Scholar
  6. Breiman L (2001) Random forests. Mach Learn. doi: 10.1023/A:1010933404324 zbMATHGoogle Scholar
  7. Calderón A, Espinosa A (2006) Ideología política, valores culturales y miedo a la muerte: su impacto después de los atentados del 11 de Marzo. Psicología Política 32:33–38Google Scholar
  8. Canel MJ (1999) Comunicación política: técnicas y estrategias para la sociedad de la información. Tecnos, MadridGoogle Scholar
  9. Casero-Ripollés A, Feenstra R (2012) The 15-M movement and the new media: a case study of how new themes were introduced into spanish political discourse. Media Int Aust. doi: 10.1177/1329878X1214400111 Google Scholar
  10. Colleoni E et al (2014) Echo chamber or public sphere? predicting policital orientation and measuring political hemophily in Twitter using big data. J Commun. doi: 10.1111/jcom.12084 Google Scholar
  11. Congosto M et al (2011) Twitter y política: información, opinión y ¿predicción? Cuadernos de comunicación Evoca 4:11–16Google Scholar
  12. Cordero G (2008) ¿ Qué es ideología? El caso español. Universidad Autónoma de Madrid, MadridGoogle Scholar
  13. Del Fresno M et al (2015) Unveiling climates of opinion through social media mining and social network analysis in Twitter. The case of common core state standards. Redes. Revista hispana para el análisis de redes sociales. doi: 10.5565/rev/redes.531 Google Scholar
  14. Deltell L (2012) Estrategias de comunicación política en las redes sociales durante la campaña electoral del 2011 en España: el caso de eQuo. Asociación de Sociología Madrileña, MadridGoogle Scholar
  15. Deltell L et al (2013) Predicción de tendencia política por Twitter: Elecciones Andaluzas 2012. Ambitos Revista internacional de comunicación 22:91–100Google Scholar
  16. Denzau A, North D (1994) Shared mental models: ideologies and institutions. Kyklos. doi: 10.1111/j.1467-6435.1994.tb02246.x Google Scholar
  17. Elmer G (2012) Live research: Twittering an election debate. New Media Soc. doi: 10.1177/1461444812457328 Google Scholar
  18. Flach P (2012) Machine learning: the art and science of algorithms that make sense of data. Cambrige Press University, CambrigeCrossRefzbMATHGoogle Scholar
  19. Fominaya CF (2014) Social movements and globalization: how protests, occupations and uprisings are changing the world. Palgrave Macmillan, New YorkCrossRefGoogle Scholar
  20. Gimpel K et al (2011) Part-of-speech tagging for Twitter: annotation, features, and experiments’, in Association for Computational Linguistics. Association for Computational Linguistics, BaltimoreGoogle Scholar
  21. Gruzd A, Roy J (2014) Investigating political polarization on Twitter: a Canadian perspective. Policy Internet. doi: 10.1002/1944-2866 Google Scholar
  22. Iyyer M et al (2014) Political ideology detection using recursive neural networks. Association for Computational Linguistics, BaltimoreCrossRefGoogle Scholar
  23. Jost JT (2006) The end of the end of ideology. Am Psychol. doi: 10.1037/0003-066X.61.7.651 Google Scholar
  24. Koc-Michalska K et al (2014) Poland’s 2011 online election campaign: new tools, new professionalism, new ways to win votes. J Inf Technol Politics. doi: 10.1080/19331681.2014.899176 Google Scholar
  25. Levy Paul S, Lemeshow S (2013) Sampling of populations: methods and applications. John Wiley & Sons, New JerseyzbMATHGoogle Scholar
  26. López TR et al (2013) The political communication in the “Social media”: comparative analysis of the campaign of Barack Obama and Hillary Clinton in 2008. Historia y Comun Soc. doi: 10.5209/rev_HICS.2013.v18.44367 Google Scholar
  27. Margolis M, Resnick D (2000) Politics as usual: the cyberspace “Revolution”. SAGE Publications, Thousand OaksGoogle Scholar
  28. Marlin-Bennett R (2011) I hear America tweeting and other themes for a virtual polis: rethinking democracy in the global infotech age. J Inf Technol Politics. doi: 10.1080/19331681.2011.532675 Google Scholar
  29. Mayer-Schönberger V, Cukier K (2013) Big data: a revolution that will transform how we live, work, and think. Mariner Books, BostonGoogle Scholar
  30. Oshiro TM, Perez PS, Baranauskas JA (2012) How many trees in a random forest? In: 8th International Conference on Machine Learning and Data Mining (MLDM’2012). Volume 7376 of Lecture Notes in Computer Science pp 154–168Google Scholar
  31. Pedregosa F et al (2011) Scikit-learn: machine learning in Python. J Mach Learn Res. doi: 10.1016/j.patcog.2011.04.006 MathSciNetzbMATHGoogle Scholar
  32. Puddington A (2013) Freedom in the World 2013: Democratic Breakthroughs in the Balance. Freedom House, Washington. Accessed 21 Jun 2016
  33. Quinlan JR (1986) Induction of decision trees. Mach Learn. doi: 10.1023/A:1022643204877 Google Scholar
  34. Robins D, Frati FE, Alvarez J, Texier J (2016) Balotage in Argentina 2015, a sentiment analysis of tweets. Accessed 21 Jun 2016Google Scholar
  35. Rodríguez R, Ureña D (2011) Diez razones para el uso de Twitter como herramienta en la comunicación política y electoral. Comunicación y pluralismo 10:89–107Google Scholar
  36. Salton G et al (1975) A vector space model for automatic indexing. Commun ACM. doi: 10.1145/361219.361220 zbMATHGoogle Scholar
  37. Sánchez G, Sánchez R (2009) Ideological orientations of citizens in Europe. Papel Politico 14:645–667Google Scholar
  38. Segerberg A, Bennett WL (2011) Social media and the organization of collective action: using Twitter to explore the ecologies of two climate change protests. Commun Rev. doi: 10.1080/10714421.2011 Google Scholar
  39. Tayal DK, Yadav SK (2016) Sentiment analysis on social campaign “Swachh Bharat Abhiyan” using unigram method. AI & Soc. doi: 10.1007/s00146-016-0672-5 Google Scholar
  40. Wagner KM, Gainous J (2013) Digital uprising: the internet revolution in the Middle East. J Inf Technol Politics. doi: 10.1080/19331681.2013.778802 Google Scholar
  41. Wu HC et al (2008) Interpreting TF-IDF term weights as making relevance decisions. ACM Trans Inf Syst. doi: 10.1145/1361684.1361686 Google Scholar
  42. Xu G, Li L (2013) Social media mining and social network analysis: emerging research, information. Science reference. IGI Global, HersheyCrossRefGoogle Scholar

Copyright information

© Springer-Verlag London Ltd. 2017

Authors and Affiliations

  1. 1.Federal University of ABC, BrazilSanto AndréBrazil
  2. 2.International University of the RiojaMajadahondaSpain

Personalised recommendations