Log inStart free
LESSON 4.12 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Logistic regression

Watch a sigmoid turn a straight-line score into a probability and a boundary.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.12 · CLASSIFIER BAYW = (−0.5, 1) · B = 0.5 · FIRST GUESS
01
Stage 1 of 6 · Linear score
Logistic regression gives each point a linear score z = w·x + b. It grows along the arrow w.
Explain it simply

Each teal mark is a point with two features, x₁ and x₂. Dots have the label 1, and squares have the label 0. The score multiplies each feature by its weight and adds the bias b. The grey lines join spots with the same score, and they all cross the ochre arrow w at right angles.

Twelve points on a plane: six dots with label 1 and six squares with label 0. The first guess is w = (−0.5, 1) and b = 0.5. Grey lines of equal score cross the arrow w. Point 1 has the score 0.65.

points: dot y = 1, square y = 0weights w and bias bprobability p and the boundarylog loss and wrong pointslines of equal score
feature plane−2−2−1−1001122x₁x₂z = −2z = −1z = 0z = 1z = 2w123456789101112z = −0.5·x₁ + 1·x₂ + 0.5sigmoid−6−4−20246zfeature plane−2−2−1−1001122x₁x₂z = −2z = −1z = 0z = 1z = 2w123456789101112z = −0.5·x₁ + 1·x₂ + 0.5sigmoid−6−4−20246z
Toy: 12 points · 2 features · 3 parameters (w₁, w₂, b) · full-batch steps, η = 1
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
z=w1 x1+w2 x2+b\sy{z}{out}{z} = \sy{w}{param}{w_1}\,\sy{x}{data}{x_1} + \sy{w}{param}{w_2}\,\sy{x}{data}{x_2} + \sy{b}{param}{b}
z1=−0.5⋅1.3+1⋅0.8+0.5=0.65z_1 = -0.5\cdot 1.3 + 1\cdot 0.8 + 0.5 = 0.65

The score adds each feature times its weight, plus the bias b.

Common mix-ups

MYTHThe sigmoid bends the decision boundary into a curve.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If the threshold goes from 0.5 to 0.8, what does the boundary do?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.