Lecture 5 · Mon, 26 Oct 2026 · Leif Anders Thorsrud & Vegard H. Larsen

Practical day 1

Hands-on workflows with NLTK, scikit-learn, and Gensim — POS tagging, TF-IDF, and LDA topic models — plus guidance on the assignments

Open slides

Overview

A working session, not a lecture: laptops open from the start. Three short demos put the lecture 1–3 toolkit to work — part-of-speech tagging with NLTK, TF-IDF with scikit-learn, and a full LDA topic model with Gensim on 2,000 newsgroup posts (the complete pipeline: clean → tokenize → filter → dictionary → bag-of-words → model). The second half is a supervised work block on assignment 1 with your group; we circulate.

Bring

  • A laptop with a working Python setup — see Tools; if your environment is broken, today is the day we fix it
  • Your group’s assignment problem — data, questions, half-broken code all welcome

Materials

  • Slides: use the Open slides button above
  • Notebook: practical_day_1.ipynb — the three demos plus working-with-code tips. The LDA demo fetches the 20 Newsgroups dataset automatically; no data download needed. First run requires the commented-out nltk.download(...) lines.

Before lecture 6

  • Read Kozlowski et al. (2019) — discussed in the embeddings lecture
  • Keep your notebook environment alive — practical day 2 builds on it

GRA 4164 Text as Data · Fall 2026 · BI Norwegian Business School