Interactive Lab · AI/ML Foundations
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
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
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
σ(z)=1/(1+e−z) squashes any real score into a (0,1) probability, no matter how big or negative z gets.z = w·x + b fed through that squash. w sets how sharply it decides; b slides the whole curve left/right.p = 0.5 (i.e. x = −b/w) is the decision boundary, one side predicts YES, the other NO.