Linear regression predicts a number. Logistic regression predicts a probability and draws a line between two classes. Add points, bend the boundary, and watch a model learn to say “yes” or “no”.
First the model computes a score z = w₁x₁ + w₂x₂ + b, exactly like linear regression. That score can be any number, so the sigmoid squashes it into 0 to 1: p = 1 ÷ (1 + e−z). Below, every point sits on the curve at its own score. Class 1 points should land high on the right, class 0 low on the left.
Suppose a point truly belongs to class 1. If the model says p = 0.99 the cost is tiny. If it says p = 0.01 (confidently wrong) the cost explodes. Log-loss grows without limit as the model becomes confidently wrong, while squared error is capped at 1. That steep penalty is what drives learning. Drag the slider.
Start from any boundary and nudge the three numbers downhill on the log-loss. Remarkably, the gradient has the same shape as in linear regression: (prediction − truth) times the input. Only the prediction is now a probability.
The model outputs a probability. You choose the cut-off for saying “class 1”. Slide it and watch the boundary in the main chart move, the confusion matrix change, and the dot travel along the ROC curve.
Logistic regression is linear in the log-odds. So adding 1 to a feature multiplies the odds of class 1 by ew.
When classes mix, no boundary is perfect. Watch accuracy and log-loss hit a ceiling.
Drop the threshold to 0.2. Recall rises, but more false alarms appear.
With no overlap, the weights grow forever and the loss creeps to zero.