Chapter 1: Classical ML

From a line to a probability: the sigmoid

Many real questions have a yes-or-no answer, such as "will this customer stay?" or "is this email spam?". Interviewers often open with "why not just use a line for this?", and the answer is the sigmoid. You will be able to turn a line's score into a probability, and explain why the result always lies between 0 and 1.

7 minInteractive lessonChapter 1: Classical MLLesson 4 of 25

What you will learn

  • Explain why a sigmoid turns a line into a probability

Key terms

probability
a chance from 0 (never) to 1 (certain)
score z
the number that a line gives for one input
weight w
the slope of the line
sigmoid σ
a rule that changes a score into a probability

Prerequisites

Take The exact best line: two equations, and MAE first. It comes right before this lesson in the course.

Where this lesson picks up: You found the exact least-squares line and used MAE to say how far off its predictions are on average. But fit a line to yes-or-no labels, and it can predict 1.4, which cannot be a chance.

What comes next

The model now says 0.7 for a customer who stayed: how do we score that guess, and which way should the model's slope move?

Next lesson: Training logistic regression: log loss, its gradient, and why not squared error

More lessons in this part

Take the lesson

Short cards, one idea at a time, with quick checks as you go.