Political Text Analysis
(academic year 2026/27)
Syllabus
Course aims and objectives
The course begins with the fundamentals of text representation, including text pre-processing and the bag-of-words approach. It then introduces a range of methods for extracting information from texts, moving from unsupervised approaches that discover latent themes in documents to supervised machine learning techniques that classify texts into predefined categories. Particular attention is devoted to the validation and interpretation of machine learning models. The course concludes with an introduction to static word embedding methods, focusing on how distributed representations of words can capture semantic relationships that go beyond traditional bag-of-words models.
First Lecture - Room 3-902
03/12/26 10:40 AM - 12:20 PM Theory: An introduction to text analytics: the Bag-of-Words approach
Reference texts: (1; 2)
Second Lecture - Room 3-902
07/12/26 10:40 AM - 12:20 PM Theory: Unsupervised classification methods: the Topic Model
Reference text (1; 2):
07/12/26 5:00 PM -6:40 PM Lab class: How to implement a Topic Model. a) packages to install for Lab 2; b) script for Lab 2 - R script; Google Colab notebook; dataset: NyT economic articles (.rds)
Third Lecture - Room 3-902
10/12/26 10:40 AM - 12:20 PM Theory: (part 1): The Structural Topic model; (part 2): Supervised classification methods: automatic tagging
Reference text (1; 2):
First assignment (due: 17 December 2026): (dataset for the first part: dataset about lyrics of songs; dataset for the second part: Guardian 2016 (.csv; .rds); dataset for the third part: Trump 2018 tweets). Note: to open a .rds file, use the command readRDS("NAME OF THE FILE.rds")
Fourth Lecture - Room 3-902
14/12/26 10:40 AM - 12:20 PM Theory: (part 1): An introduction to supervised classification models; (part 2): Supervised classification models: Random Forest
Reference text (1; 2, 3):
14/12/26 5:00 PM -6:40 PM Lab class: How to implement a Random Forest model. a) packages to install for Lab 4; b) script for Lab 4- R script; Google Colab notebook. datasets for Lab 4: a) disaster dataset - training-set (.csv; .rds); b) disaster dataset - test-set (.csv; .rds); c) US airlines training-set (.csv; .rds); d) US airlines test-set (.csv; .rds); EXTRA: Meaning of a compressed sparse matrix
Fifth Lecture - Room 3-902
17/12/26 10:40 AM - 12:20 PM Theory: (part 1): Supervised classification models: Naïve Bayes models; (part 2): How to validate a ML algorithm: cross-validation
Reference text (1, 2; 3):
17/12/26 5:00 PM -6:40 PM Lab class: How to implement supervised classification model: NB and how to compute external validity of a ML algorithm. a) packages to install for Lab 5; b) Scripts for Lab 5 (part I: Naïve Bayes - R script; Google Colab Notebook; part II: external validity - R script; Google Colab Notebook; c) functions to compute cross-validation; d) .rds for the grid-search of different ML algorithms (to open the file, please use the data compression tool WinRAR). Dataset for Lab 6: training-set
Second assignment (due: 24 December 2026): (dataset for the assignment - Training set: .csv; .rds; Test set: .csv; .rds)
Sixth Lecture - Room 3-902
21/12/26 10:40 AM - 12:20 PM Theory: (part 1): Global Interpretation; (part 2): The importance of a good training set
Reference text (1):
21/12/26 5:00 PM -6:40 PM Lab class: How to compute a global interpretation of a ML algorithm and running an inter-coder reliability test. a) packages to install for Lab 6; b) (part 1): script for Lab 6 - R script; Google Colab notebook; (part 2): R script; Google Colab notebook.
Seventh Lecture - Room 3-902
07/01/27 10:40 AM - 12:20 PM Theory: Static Word Embedding techniques
Reference texts (1):
07/01/27 5:00 PM -6:40 PM Lab class: How to compute static WE. a) packages to install for Lab 7; b) Script for Lab 7. computing stating WE - R script; Google Colab Notebook; c) movie reviews dataset (.csv; .rds); d) social-disaster dataset (.csv; .rds); e) pre-trained WE on Google news; f) pre-trained WE on Facebook posts. EXTRA 1: hybrid representation with WE; EXTRA 2: feature importance with WE
Third assignment (due: 14 January 2027)
The course begins with the fundamentals of text representation, including text pre-processing and the bag-of-words approach. It then introduces a range of methods for extracting information from texts, moving from unsupervised approaches that discover latent themes in documents to supervised machine learning techniques that classify texts into predefined categories. Particular attention is devoted to the validation and interpretation of machine learning models. The course concludes with an introduction to static word embedding methods, focusing on how distributed representations of words can capture semantic relationships that go beyond traditional bag-of-words models.
First Lecture - Room 3-902
03/12/26 10:40 AM - 12:20 PM Theory: An introduction to text analytics: the Bag-of-Words approach
Reference texts: (1; 2)
- Grimmer, Justin, and Stewart, Brandon M. 2013. Text as Data: The Promise and Pitfalls of Automatic Content Analysis Methods for Political Texts. Political Analysis, 21(3): 267-297
- Benoit, Kenneth (2020). Text as data: An overview. In Luigi Curini and Robert Franzese (eds.), SAGE Handbook of Research Methods is Political Science & International Relations, London, Sage, chapter 26
Second Lecture - Room 3-902
07/12/26 10:40 AM - 12:20 PM Theory: Unsupervised classification methods: the Topic Model
Reference text (1; 2):
- Grimmer, Justin, and Stewart, Brandon M. 2013. Text as Data: The Promise and Pitfalls of Automatic Content Analysis Methods for Political Texts. Political Analysis, 21(3): 267-297
- Robert, Margaret E., Brandon M. Stewart, Dustin Tingley, Christopher Luca, Jetson Leder-Luis, Shana Kushner Gadarian, Bethany Albertson, David G. Rand. 2014. Structural Topic Models for Open-Ended Survey Response. American Journal of Political Science, 58(4), 1064-1082
07/12/26 5:00 PM -6:40 PM Lab class: How to implement a Topic Model. a) packages to install for Lab 2; b) script for Lab 2 - R script; Google Colab notebook; dataset: NyT economic articles (.rds)
Third Lecture - Room 3-902
10/12/26 10:40 AM - 12:20 PM Theory: (part 1): The Structural Topic model; (part 2): Supervised classification methods: automatic tagging
Reference text (1; 2):
- Grimmer, Justin, and Stewart, Brandon M. 2013. Text as Data: The Promise and Pitfalls of Automatic Content Analysis Methods for Political Texts. Political Analysis, 21(3): 267-297
- Robert, Margaret E., Brandon M. Stewart, Dustin Tingley, Christopher Luca, Jetson Leder-Luis, Shana Kushner Gadarian, Bethany Albertson, David G. Rand. 2014. Structural Topic Models for Open-Ended Survey Response. American Journal of Political Science, 58(4), 1064-1082
First assignment (due: 17 December 2026): (dataset for the first part: dataset about lyrics of songs; dataset for the second part: Guardian 2016 (.csv; .rds); dataset for the third part: Trump 2018 tweets). Note: to open a .rds file, use the command readRDS("NAME OF THE FILE.rds")
Fourth Lecture - Room 3-902
14/12/26 10:40 AM - 12:20 PM Theory: (part 1): An introduction to supervised classification models; (part 2): Supervised classification models: Random Forest
Reference text (1; 2, 3):
- Olivella, Santiago, and Shoub Kelsey (2020). Machine Learning in Political Science: Supervised Learning Models. In Luigi Curini and Robert Franzese (eds.), SAGE Handbook of Research Methods is Political Science & International Relations, London, Sage, chapter 56
- Curini, Luigi, and Robert Fahey. 2020. Sentiment Analysis. In: Luigi Curini and Robert Franzese (eds.), Sage Handbook of Research Methods in Political Science and International Relations, London: Sage, chapter 29
- Barberá, Pablo et al. (2020). Automated Text Classification of News Articles: A Practical Guide. Political Analysis, DOI: 10.1017/pan.2020
14/12/26 5:00 PM -6:40 PM Lab class: How to implement a Random Forest model. a) packages to install for Lab 4; b) script for Lab 4- R script; Google Colab notebook. datasets for Lab 4: a) disaster dataset - training-set (.csv; .rds); b) disaster dataset - test-set (.csv; .rds); c) US airlines training-set (.csv; .rds); d) US airlines test-set (.csv; .rds); EXTRA: Meaning of a compressed sparse matrix
Fifth Lecture - Room 3-902
17/12/26 10:40 AM - 12:20 PM Theory: (part 1): Supervised classification models: Naïve Bayes models; (part 2): How to validate a ML algorithm: cross-validation
Reference text (1, 2; 3):
- Cranmer, Skyler J. and Desmarais, Bruce A. (2017) What Can We Learn from Predictive Modeling?, Political Analysis, 25: 145-166
- Arnold, Christian, Biedebach Luka, Küpfer Andreas, and Neunhoeffer Marcel. (2023). The Role of Hyperparameters in Machine Learning, Political Science Research and Methods, 2024
- Park, Ju Yeon, and Jacob M. Montgomery. Toward a framework for creating trustworthy measures with supervised machine learning for text. Political Science Research and Methods (2025): 1-17
17/12/26 5:00 PM -6:40 PM Lab class: How to implement supervised classification model: NB and how to compute external validity of a ML algorithm. a) packages to install for Lab 5; b) Scripts for Lab 5 (part I: Naïve Bayes - R script; Google Colab Notebook; part II: external validity - R script; Google Colab Notebook; c) functions to compute cross-validation; d) .rds for the grid-search of different ML algorithms (to open the file, please use the data compression tool WinRAR). Dataset for Lab 6: training-set
Second assignment (due: 24 December 2026): (dataset for the assignment - Training set: .csv; .rds; Test set: .csv; .rds)
Sixth Lecture - Room 3-902
21/12/26 10:40 AM - 12:20 PM Theory: (part 1): Global Interpretation; (part 2): The importance of a good training set
Reference text (1):
- Soren Jordan, Hannah L. Paul, Andrew Q. Philips, How to Cautiously Uncover the “Black Box” of Machine Learning Models for Legislative Scholars”, Legislative Studies Quarterly, 2022, https://onlinelibrary.wiley.com/doi/abs/10.1111/lsq.12378
21/12/26 5:00 PM -6:40 PM Lab class: How to compute a global interpretation of a ML algorithm and running an inter-coder reliability test. a) packages to install for Lab 6; b) (part 1): script for Lab 6 - R script; Google Colab notebook; (part 2): R script; Google Colab notebook.
Seventh Lecture - Room 3-902
07/01/27 10:40 AM - 12:20 PM Theory: Static Word Embedding techniques
Reference texts (1):
- Rodriguez Pedro L. and Spirling Arthur (2022). Word Embeddings: What works, what doesn’t, and how to tell the difference for applied research, Journal of Politics, 84(1), 101-115
07/01/27 5:00 PM -6:40 PM Lab class: How to compute static WE. a) packages to install for Lab 7; b) Script for Lab 7. computing stating WE - R script; Google Colab Notebook; c) movie reviews dataset (.csv; .rds); d) social-disaster dataset (.csv; .rds); e) pre-trained WE on Google news; f) pre-trained WE on Facebook posts. EXTRA 1: hybrid representation with WE; EXTRA 2: feature importance with WE
Third assignment (due: 14 January 2027)