Skip to main content

Analyzing Twitter networks using graph embeddings: an application to the British case


Embeddings have gained traction in the social sciences in recent years. Existing work focuses on text-as-data to estimate word embeddings. In this paper, we turn to graph embeddings as a tool whose use has been overlooked in the analysis of social networks. Graph embeddings have two primary uses. First, to encode users and their interactions onto a single vector. Second, graph embeddings can be used as inputs for machine-learning classifiers. In this paper, we use the British political Twitter to illustrate both uses of graph embeddings. We encode users’ partisanship. Furthermore, we use an SVM and a NN to estimate the partisan proximity of Twitter users. Results suggest that graph embeddings yield high precision predictions.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3
Fig. 4


  1. There are several legislators whose Twitter activity puts them below this threshold. This decreases our number of legislators to 561.


  3. Results are robust to changes in dimensions (20, 30, 40, 50, 100, and 150). For computational parsimony, we use ten dimensions. Results using different dimensions are available authors.

  4. We acknowledge that legislators tweet about other topics as well. However, their utterances tend to be dominated by political matters.

  5. We define outliers as users whose Twitter bio identifies them as Labour and Liberal Democrats but our embedding, based on their Twitter activities, puts them in the vicinity of the Conservatives. To be sure, there are outliers in other areas of the graph. However, the observation of the graph suggests that the highlighted area has a particularly high number of outliers.

  6. Results and technical notes are available from the authors.

  7. N Outliers: 103 N Conservative: 246 N Tweets: 3003.

  8. Tables S2–S5 in the online appendix show results per party.

  9. We use ‘predict_proba’ property of the SVC function in the scikit-learn.


  1. Barberá, P. (2015). Birds of the same feather tweet together: Bayesian ideal point estimation using Twitter data. Political Analysis, 23(1), 76–91.

    Article  Google Scholar 

  2. Barberá, P., Jost, J. T., Nagler, J., Tucker, J. A., & Bonneau, R. (2015). Tweeting from left to right: Is online political communication more than an echo chamber? Psychological Science, 26(10), 1531–1542.

    Article  Google Scholar 

  3. Cai, H., Zheng, V. W., & Chang, K.C.-C. (2018). A comprehensive survey of graph embedding: Problems, techniques, and applications. IEEE Transactions on Knowledge and Data Engineering, 30(9), 1616–1637.

    Article  Google Scholar 

  4. Goyal, P., & Ferrara, E. (2018). Graph embedding techniques, applications, and performance: A survey. Knowledge-Based Systems, 151, 78–94.

    Article  Google Scholar 

  5. Grover, A. & Leskovec, J. (2016). node2vec: Scalable feature learning for networks. In Proceedings of the 22nd ACM SIGKDD international conference on Knowledge discovery and data mining. ACM pp. 855–864.

  6. Hamdi, T., Slimi, H., Bounhas, I., & Slimani, Y. (2020). A hybrid approach for fake news detection in twitter based on user features and graph embedding. In International Conference on Distributed Computing and Internet Technology. Springer pp. 266–280.

  7. Harris, Z. S. (1954). Distributional structure. Word, 10(2–3), 146–162.

    Article  Google Scholar 

  8. Hobolt, S. B., et al. (2018). Brexit and the 2017 UK general election. Journal of Common Market Studies, 56(S1), 39–50.

    Article  Google Scholar 

  9. Laver, M. (2014). Measuring policy positions in political space. Annual Review of Political Science, 17, 207–223.

    Article  Google Scholar 

  10. Masood, M.A., & Abbasi, R.A. (2021). Using graph embedding and machine learning to identify rebels on Twitter. Journal of Informetrics, 15(1), 101–121.

    Article  Google Scholar 

  11. Mikolov, T., Chen, K., Corrado, G., & Dean, J. (2013). Efficient estimation of word representations in vector space. arXiv preprint arXiv:1301.3781.

  12. Mikolov, T., Sutskever, I., Chen, K., Corrado, G.S., & Dean, J. (2013). Distributed representations of words and phrases and their compositionality. In Advances in neural information processing systems. pp. 3111–3119.

    Google Scholar 

  13. Řehůřek, R., & Sojka, P. (2010). Software framework for topic modelling with large corpora. In Proceedings of the LREC 2010 Workshop on New Challenges for NLP Frameworks. Valletta, Malta: ELRA pp. 45–50.

  14. Rheault, L., & Cochrane, C. (2020). Word embeddings for the analysis of ideological placement in parliamentary corpora. Political Analysis, 28(1), 112–133.

    Article  Google Scholar 

  15. Rodman, E. (2020). A timely intervention: Tracking the changing meanings of political concepts with word vectors. Political Analysis, 28(1), 87–111.

    Article  Google Scholar 

  16. Spirling, A., & Rodriguez, P. (forthcoming). Word embeddings: What works, what doesn’t, and how to tell the difference for applied research.” Journal of Politics forthcoming.

  17. van der Maaten, Laurens, & Hinton, Geoffrey. (2008). Visualizing data using t-SNE. Journal of Machine Learning Research, 9(Nov), 2579–2605.

    Google Scholar 

Download references


The authors would like to thank Pablo Barberá, Michael Laver, Christopher Cochrane, and Carsten Schwemmer for helpful comments of early drafts. The usual disclaimer applies.

Author information

Authors and Affiliations


Corresponding author

Correspondence to Jorge M. Fernandes.

Ethics declarations

Conflict of interest

On behalf of all authors, the corresponding author states that there is no conflict of interest.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Supplementary Information

Below is the link to the electronic supplementary material.

Supplementary material 1 (PDF 44 KB)

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Won, M., Fernandes, J.M. Analyzing Twitter networks using graph embeddings: an application to the British case. J Comput Soc Sc 5, 253–263 (2022).

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI:


  • Graph embeddings
  • Social networks
  • Social media
  • Twitter
  • Political map
  • UK