NLP BasicsLesson 4
Lesson 48 min
Text Classification
Sorting text into categories — the most common NLP task.
What you will learn
- ✓The classify pipeline
- ✓Examples like spam and sentiment
- ✓Why a labelled dataset matters
Explanation
Text classification assigns a label to a piece of text — spam/not-spam, positive/negative, ticket category.
The classic pipeline is: tokenise → embed → classifier (e.g. logistic regression). You train it on labelled examples.
It's everywhere because it's simple, fast, and useful — and you can often do it with a small model instead of a costly LLM.
Code Example
python
| 1 | |
| 2 | |
| 3 | |
| 4 | |
Real-world use
Support desks auto-route tickets to the right team using text classification on the message body.
Common mistakes
- • Reaching for an LLM when a small, cheap classifier would handle high-volume sorting.
Practice
Pick a text-classification task and list the categories and the labelled data you'd need.
Knowledge check
0/1 answered1. Spam detection is an example of...
Answer all questions to check.