Course contentsShow
← Machine Learning and Deep Learning
Lesson 257 of 3,5384. Classification with Logistic RegressionFree lesson

From Binary to Multiclass Classification

Understanding how classification extends beyond two classes and why logistic regression needs adaptation for multiple categories.

From Binary to Multiclass Classification

What you'll learn: How classification problems expand beyond two categories and why logistic regression needs modifications to handle multiple classes.

Beyond Yes or No

So far, you've worked with binary classification—problems with exactly two possible outcomes (spam/not spam, sick/healthy, cat/dog). But the real world rarely limits itself to two choices. What if you need to classify images into ten digit categories (0–9)? Or predict which of five product categories a customer will buy?

This is multiclass classification: predicting one label from three or more mutually exclusive classes.

Why Logistic Regression Needs Adaptation

Remember that logistic regression uses the sigmoid function to output a probability between 0 and 1 for a single class. That works beautifully for binary problems—if P(class=1) = 0.8, then P(class=0) = 0.2.

But with three or more classes, you need probabilities for each class that all sum to 1.0. The sigmoid function alone can't do this. You need a way to:

  1. Generate multiple outputs (one per class)
  2. Ensure all outputs are valid probabilities (between 0 and 1)
  3. Ensure they sum to exactly 1.0

Two Common Approaches

One-vs-Rest (OvR): Train separate binary classifiers—one treats class A as positive and all others as negative, another for class B, etc. Then pick the class with highest confidence.

Softmax Regression: A direct extension that generalizes the sigmoid to multiple classes, outputting a probability distribution across all categories simultaneously.

Key Takeaway: Multiclass classification requires adapting binary methods because you need a probability distribution across multiple classes, not just a single probability. Logistic regression extends through strategies like One-vs-Rest or the softmax function.