Machine Learning, FoundationsLesson 19 of 92

Module 2 · Linear models and the machinery of fitting

More than two classes, and what changes

In this lesson

  • 8 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 10 of 10 in this chapter

This chapter’s goalFit and diagnose a linear or logistic model end to end: compute its loss by hand on a handful of rows, tune the learning rate from the shape of the loss curve, state what a coefficient does and does not mean in the units of the data, and explain what ridge and lasso penalties change about the fitted parameters.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch1:58Not available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

Two strategies

Logistic regression is built for two classes. Real problems have four, or fifty, or three thousand. There are two ways to get there and they behave differently.

One-vs-rest. Train one binary classifier per class: “is it A or not”, “is it B or not”, and so on. To predict, run all of them and take the highest score. With 50 classes you train 50 models.

Simple and it works with any binary classifier. Two weaknesses: each classifier sees a badly imbalanced problem (one class against 49), and the scores come from independently fitted models, so they are on different scales and do not sum to 1. Comparing them is a bit of a fudge.

Multinomial (softmax). One model, with one weight vector per class, all fitted together against a single loss. For each row, compute a score per class and convert the whole vector to probabilities at once:

Text
p_k = exp(s_k) / sum over all j of exp(s_j)

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the How a Language Model Actually Works exam.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘More than two classes, and what changes’, in Machine Learning, Foundations. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/machine-learning-foundations/more-than-two-classes (Accessed: 29 November 2026).