demo · 02-ml-fundamentals

Logistic regression — the boundary and the squish

Three sliders control w₁, w₂, and bias. The decision boundary (where w₁x₁ + w₂x₂ + b = 0) tilts in real time. Below it, the sigmoid curve shows how the linear score gets squashed to a probability. Cross-entropy loss updates live.

Why it matters

Logistic regression is the simplest classification model that outputs a calibrated probability. The sigmoid function σ(z) = 1/(1+e⁻ᶻ) maps any real number to (0,1). Cross-entropy loss makes the model push probabilities toward 0 or 1 for the wrong class. This is the building block behind every neural network output layer for classification.

The math

z = w₁x₁ + w₂x₂ + b
P(y=1 | x) = σ(z) = 1 / (1 + e⁻ᶻ)

Loss = −(1/n) Σ [yᵢ log σ(zᵢ) + (1−yᵢ) log(1−σ(zᵢ))]

Anchored to 02-ml-fundamentals/supervised-learning.