CourseNatural Language Processing: The Complete Course · Module 4: Text as Vectors and Classification · part 30 of 73
Part 30 · Module 4: Text as Vectors and Classification

Lab: The first trained intent classifier, versioned

66 min read·14 Oct 2026
Module 4 · Lab · About 60 minutes · Needs: lessons 1 to 4 of this module, and the Module 3 lab (or its cells, pasted here)

What you are building

SETTLED FROM FOUR LESSONS inbox/features.py inbox/classify.py tests/test_classify.py WHAT ROSA GETS beats the rules: 0.613 vs 0.438 scores per language models/ version 1 + card served through predict(texts), like every intent model
The lab settles two files (blue), shows the trained model beating the rules on hand-written mail (green) and saves version 1, which is never committed (grey).

It is project week 4, and Rosa wants a trained router that beats the keyword rules from Module 1. The four lessons each appended parts to two files: word counts, n-grams and TF-IDF to inbox/features.py, naive Bayes and logistic regression to inbox/classify.py. This lab settles each file into one version with one test file, picks the regularisation strength on the dev split, and scores the rules, naive Bayes and logistic regression side by side on the template test split and on Ines's 80 hand-written messages, language by language. Last, it saves the logistic regression as version 1 of a pipeline, with a JSON card, and serves it through the course's predict(texts).

Open a new Colab notebook, call it module-04-lab.ipynb, and run each cell in order.

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.