Math

Logistic Regression

Logistic regression predicts a probability between 0 and 1. Training pushes the sigmoid boundary to separate the classes while keeping probabilities calibrated.

7 minLevel 3/3The interactive stage stays ad-free.
Accuracy100.0%Log loss0.023Weights2.57, 2.41Bias0.23

The model learns a linear score w·x + b, then applies the sigmoid to produce a probability. The amber line is where the probability is exactly 0.5. Logistic regression is a classifier, not a regression line: it minimizes log loss rather than squared error.

What you are seeing

1

A linear score z = w·x + b is passed through the sigmoid 1/(1 + e⁻ᶻ) to produce a probability.

2

The decision boundary is where the probability equals 0.5, which is the line z = 0.

3

Gradient descent minimizes log loss, adjusting w and b to fit the labels.

Why it matters

Logistic regression is a foundational classifier in statistics and machine learning, and its probabilities are easier to interpret than raw scores.

Complexity & details

Each gradient step costs O(n) for n samples. Prediction is O(d) for d features.

Frequently asked questions

Why use sigmoid instead of a step function?+

The sigmoid is smooth and differentiable, so gradients can update the parameters. It also outputs a probability rather than a hard 0/1 label.

Can logistic regression handle nonlinear boundaries?+

Plain logistic regression is linear in the features. Adding polynomial or transformed features lets it learn nonlinear boundaries.