Machine Learning

Linear Models

Linear regression and logistic regression are one model in two costumes. Both score an input with the same straight line, z = wx + b. Change what that score turns into and how its error is counted, and the very same gradient descent fits both.

Loss
Steps0

Drag a point to move it, click empty space to add one. Run lets gradient descent find w and b on its own.

What to observe

  1. Flip between the two models and watch what actually changes. The scorez = wx + b is the same line either way. Only what it turns into changes: regression hands z back as the answer, classification squashes it into a probability between 0 and 1.
  2. Press Run in both. The same descent loop fits both models, because the gradient shown above the stage comes outidentical: (prediction − y)·x, averaged over the points.
  3. In regression, drag one point far away from the others. The whole line swings toward it, because its error is squared.
  4. In classification, drag a point across to the wrong side. The curve leans to reach it, but a probability can only ever slide between 0 and 1, so a few stragglers cannot pull the model apart the way one outlier pulls a regression line.

Shortcuts: space run/pause · s step · r reset · f fullscreen