Interactive Lab · AI/ML Foundations

Linear regression predicts a number. How do you predict YES or NO?

You can't fit a straight line to a yes/no answer, it would shoot past 1 and below 0. The trick is to bend that line into an S: the sigmoid squashes any score into a probability between 0 and 1. That's logistic regression. Drag two knobs, slope and shift, and watch the curve decide.

🎬 Watch the 90-second explainer, then bend the S to separate the classes below ↓

▶ The playground, bend the S until it separates the classes

class 0, negative (real label at p=0) class 1, positive (real label at p=1) decision boundary (p = 0.5)
accuracy = 0% avg log-loss = 0.00 boundary x = 0.0 misclassified = 0
−4 · flipped/flatsteep & confident · 6
−14 · boundary rightboundary left · 14

🧭 Where this fits

Logistic regression still runs a huge share of production ML: credit scoring, ad click-through prediction, medical risk models, anywhere you need calibrated probabilities plus explainable coefficients for a regulator. The confident-wrongness penalty you just felt is why its outputs can be trusted as actual probabilities.

The code that's actually running



  

🔮 Predict, then test

Crank w up high (toward 6) so the S becomes almost a vertical step. What happens to the curve, and to a point sitting on the wrong side of the boundary? Watch the avg log-loss number. Before you drag: why should an over-confident wrong prediction get punished so much harder than a hesitant one? (Hint: what is −log(p) when the model was 99% sure of the wrong answer?)

The takeaway

Your new mental model of logistic regression