Skip to content
AI & Machine Learning Medium #logistic-regression#classifier#sigmoid

Logistic Regression

Linear logits squashed by sigmoid. Probabilities for binary classification.

A free, animated logistic regression you can read here or embed on any website, from Scrollchart.

Logistic Regression

Logistic RegressionSigmoid squashes logit z to P(y=1|x); decision boundary at p = 0.5 (z = 0)-6-4-20246Logit z (linear score w·x + b)0.000.250.500.751.00P(y=1 | x)Decision boundaryz = 0, p = 0.5Class 0 (negative)Class 1 (positive)p 1 (asymptote)p 0 (asymptote)Key MechanicsSigmoid functionσ(z) = 1 / (1 + e⁻ᶣ)Log-odds (logit)log[p/(1-p)] = w·x + bMLE objectivemax Σ y log p + (1-y) log(1-p)Binary cross-entropyLoss = -[y log p + (1-y) log(1-p)]RegularisationL2 (Ridge) shrinks weights, prevents overfitUnlike linear regression, LR is trained via gradient descent on log-loss, not OLS; outputs are calibrated probabilities, not raw scores

1D feature vs probability with sigmoid fit. The decision boundary at p=0.5 corresponds to the threshold logit=0. 2D version shows linear boundary in feature space. MLE objective and gradient annotated.

Good for

  • Introductory ML courses teaching probabilistic binary classification and log-loss
  • Clinical and epidemiology articles where logistic regression is the standard reporting tool for odds ratios
  • Explainer content contrasting generative (Naive Bayes) vs discriminative (LR) classifier training

Source & accuracy

This logistic regression is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

From linear scores to probabilities

Logistic regression is a linear classifier for binary outcomes. It computes a linear combination of features (a dot product of feature vector and learned weights), then squashes the result through the sigmoid function, which maps any real number to a probability between 0 and 1. A raw score of 0 becomes 0.5 probability (maximum uncertainty), negative scores drop below 0.5, and positive scores rise above.

The sigmoid function is S(x) = 1 / (1 + exp(-x)). This smooth S-shape provides two benefits: it bounds predictions to valid probabilities, and its derivative has a simple form, enabling efficient gradient-based learning.

Learning and interpretation

Logistic regression is trained by maximum likelihood (minimizing cross-entropy loss). The resulting weights are directly interpretable: a weight of 0.5 on feature X means a one-unit increase in X multiplies the odds of the positive class by exp(0.5) ≈ 1.65. This interpretability is a major advantage over black-box methods.

Logistic regression assumes a linear decision boundary. It cannot fit nonlinear patterns without feature engineering (interactions, polynomials). But for many problems, a linear boundary is sufficient, and the simplicity, speed, and interpretability of logistic regression make it a strong baseline. It is also resistant to overfitting when regularized (L1 or L2 penalty on weights).

Embed this diagram

Add this animated logistic regression to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated logistic regression for any website.
Who uses it
AI/ML blogs, CS educators.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="logistic-regression" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "Logistic Regression" for my website?
Scrollchart provides "Logistic Regression" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a logistic regression in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.