Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Text Classification: A Practical Introduction in Python

A workshop with the Massive Data Institute, Georgetown University


One of the most common tasks in natural language processing (NLP) is classifying texts into categories: which emails are spam, which tweets are happy, etc. This method is called text classification and involves building algorithms to predict text labels. This workshop will give you hands-on experience with a typical text classification workflow, including text featurization, supervised machine learning, and model evaluation. Basic familiarity with Python is required, but no prior experience with NLP is needed.

Workshop goals

  • Get comfortable with the vocabulary of text classification
  • Understand the intuition behind supervised machine learning
  • Learn how to implement a few key supervised machine learning algorithms, including logistic regression and decision trees
  • Learn a few methods for model evaluation and how to implement, including cross-validation
  • Gain experience implementing, comparing, and optimizing machine learning models
  • Gain the foundational knowledge for continued learning


We will get our hands dirty implementing an assortment of simple web-crawling tools. To follow along with the code—which is the point—will need some familiarity with Python and Jupyter Notebooks. If you haven't programmed in Python or haven’t used Jupyter Notebooks, please do some self-teaching before this workshop using resources like those listed below.

Getting started & software prerequisites

For simplicity, just click the "Launch Binder" button (at the top of this Readme) to create a virtual environment ready for this workshop. It may take a few minutes; if it takes longer than 10, try again.

If you want to run the code on your computer, you have two options. You could use Anaconda to make installation easy: download Anaconda . Or if you already have Python 3.x installed with the full list of libraries listed under requirements.txt, you're welcome to clone this repository and follow along on your own machine. You can also install all the necessary packages like so:

pip3 install -r requirements.txt

About the presenter

Dr. Jaren Haber is a Postdoctoral Fellow with Georgetown University’s Massive Data Institute. His research applies computational methods to study how organizational contexts, social categories, and media segmentation shape the impacts of structural inequalities. He also leads the GU Interdisciplinary Text Analysis Research (GUITAR) working group. Dr. Haber received his PhD in Sociology from the University of California, Berkeley in 2020.

Online references

Supervised machine learning

Articles showing text classification in action

NLP in Python

Python and Jupyter notebooks


If you spot a problem with these materials, please make an issue describing the problem or contact Jaren at If you want to suggest additional resources or materials, please branch and make a pull request!


MDI logo


An introduction to text classification for NLP beginners with some Python know-how. Created for GU's Massive Data Institute in fall 2021 by Jaren Haber, PhD







No releases published


No packages published