Political Science

Supervised Machine Learning for Text Analysis in R

Emil Hvitfeldt; Julia Silge

A freely readable specialist text on predicting outcomes from language, with R workflows for text features, modeling, validation and model fairness.

Prerequisites

Have working knowledge of R and the basics of regression, classification and model evaluation. Familiarity with tidy data helps; this is a continuation into text, not a replacement for a general statistics course.

Difficulty Level
Intermediate
Academic Level
Graduate
political-scienceresearch-methodsspecialist reading

01 / Reading Guide

Reading Guide

Who this book is for

For political and social researchers who already use predictive models and want to analyze documents systematically. The authors address applications across fields, including legal texts; the book is listed here as a methods tool rather than a comprehensive account of political measurement. Readers need to supply a substantive research question and defensible labels.

Prerequisites

Have working knowledge of R and the basics of regression, classification and model evaluation. Familiarity with tidy data helps; this is a continuation into text, not a replacement for a general statistics course.

What it covers

Text preprocessing and feature construction lead into conventional machine-learning methods and neural approaches. The workflow makes it possible to examine how tokenization and other choices affect predictions. A classifier’s accuracy is only one part of an analysis: the relationship between labels, political concepts and the people affected also needs scrutiny.

How to use it

Create a small hand-labeled sample and document disagreements before fitting a model. Keep the evaluation documents separate from the training workflow, including preprocessing decisions. Compare a simple baseline with a more complex method and inspect errors across relevant groups. Explain what the prediction supports, and avoid turning predictive success into a causal claim.

Edition and sources

The authors’ website provides the complete online text under CC BY-NC-SA 4.0 and links its print counterpart. The preface explains the supervised-learning scope. Follow the online text’s software instructions and record package versions; printed publication details and later website dates need not identify the same revision.

Open the official resource