Module 5: Multiclass Classification and Metrics
This module extends classification to more than two classes using softmax and cross-entropy loss. It also introduces essential evaluation metrics beyond accuracy—precision, recall, F1 score, and confusion matrices—and discusses the limitations of linear models.
Learning Objectives
- Define multiclass classification and apply the softmax function.
- Compute and interpret categorical cross-entropy loss.
- Evaluate classifiers using precision, recall, F1 score, and confusion matrices.
- Understand the tradeoffs between precision and recall.
- Identify limitations of linear models and when more powerful approaches are needed.
The module in two minutes
An animated overview of the module’s through-line. Watch it before the lecture — it is the map, not the territory.
Lecture shorts
Short lectures and code walkthroughs from the instructor that reinforce this module. Some open partway into a longer video — that chapter is the part matched to this module.
Orientation audio
Beyond accuracy: how to read a classifier honestly, and what to focus on this week.
The through-line
Two classes was a warm-up; the world mostly is not binary. Softmax generalizes the sigmoid to k classes: exponentiate k scores, normalize, and read off a probability distribution. One clean idea and the same training loop — with categorical cross-entropy asking one thing only: how much probability did you put on the true class?
The heavier half of the module is measurement. Accuracy is one number, and on imbalanced data it is a liar — a model that answers "healthy" every time scores 99% on a dataset that is 99% healthy while missing every case that matters.
The confusion matrix is the honest ledger: what was predicted against what was true, per class. From it come precision (of everything flagged, how much was real?) and recall (of everything real, how much was flagged?). The two trade off against each other through the threshold you met last week; F1 collapses the pair into one number when ranking models, at the cost of hiding which side is weak.
The discipline this module installs: never report one metric for a classifier that matters. Print the confusion matrix first — it tells you not just how often the model is wrong, but which way it is wrong, and the two errors almost never cost the same.
Forty patients, eight actually sick — the imbalance that makes accuracy lie. Slide the threshold and watch all four metrics move; then try the button.
| predicted sick | predicted healthy | |
|---|---|---|
| actually sick | - | - |
| actually healthy | - | - |
"Everyone healthy" scores 80% accuracy while missing every case that matters — recall zero. The matrix is the honest ledger: precision (of everything flagged, how much was real) and recall (of everything real, how much was flagged) trade off through the threshold, and F1 collapses the pair when you need one number to rank models — at the cost of hiding which side is weak.
Key concepts
- Softmax: Maps multiple values to a probability distribution
- Cross-Entropy Loss: Measures difference between predicted and true distributions
- Precision: Of those predicted positive, how many are correct?
- Recall: Of those actually positive, how many did we find?
- Confusion Matrix: Full picture of classification performance
The lecture notebook
Six parts, from scratch before any framework. Run every cell; change things and rerun — the notebook is the lecture.
In Colab: File → Save a copy in Drive keeps your work.
Exercise
Attempt the exercise before opening the solution — the attempt is where the learning happens.
Knowledge check
The quiz is self-graded and open-book. If a question surprises you, the corresponding lecture part is the fastest fix.
Reference and discussion
Finish the module
Complete the stages above, then claim the finish here.