Start studying
Module 4 · NLP Module contents
Module 4  ·  Card 7 / 20beginner

Text Classification

Text classification sorts a document into one of a fixed set of categories.

Spam or not, ticket routing, topic labelling and intent detection are all the same task underneath.

The classic recipe turns text into TF-IDF numbers and fits any ordinary classifier on top.

The modern recipe feeds the text to a language model, either fine-tuned or simply prompted.

Accuracy misleads when one class is rare, so precision and recall are the honest measures here.

Learn in depth ↓
Module 04 · NLP · 20 concepts
In depth  /  15 lines

Text Classification, in more detail

Text classification is the oldest useful thing done with language data and it is still everywhere.

The shape never changes: a document arrives, and one label from a fixed list must come out.

Spam filtering, support ticket routing, content moderation and intent detection are all instances of it.

The classical pipeline preprocesses the text, converts it to TF-IDF vectors, and fits a classifier.

Naive Bayes and logistic regression were the workhorses, and linear models remain remarkably competitive.

That approach is fast, interpretable, needs no GPU, and gives you a strong baseline in an afternoon.

Its weakness is that it never sees meaning: a review saying not good looks positive to it.

Fine-tuning a model such as BERT fixed that by classifying from contextual representations instead.

It reads the whole sentence at once, so negation and word order finally count.

Prompting a large model removes the training step entirely and works with no labelled data at all.

The trade is cost and latency per document, which matters when you classify millions a day.

Whatever the model, the evaluation trap is the same one: class imbalance.

Real label distributions are lopsided, and a classifier that always predicts the common class can look excellent.

Precision and recall on the rare class, and the confusion matrix behind them, are what tell the truth.

Which of the two you optimise is a product decision: a missed fraud costs more than a false alarm.

Want the full technical article? Wikipedia ↗
Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
Why is accuracy a poor measure for a spam classifier?
NLP

20 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close