2.2.9 · D3Linear & Logistic Regression

Worked examples — Logistic regression and the sigmoid function

2,156 words10 min readBack to topic

Before we start, one reminder of the three symbols we lean on, so nothing is used unearned:

Recall The three symbols, in plain words

::: the linear score, . It is just a weighted sum of the inputs plus a constant. It can be any real number, negative or positive. ::: the sigmoid, . A squishy slide that turns any into a number strictly between 0 and 1 — read as . ::: the error signal: your predicted probability minus the true label. Positive means you guessed too high, negative means too low. This is the whole engine of learning.


The scenario matrix

Every case logistic regression can throw at you falls into one of these cells. Each worked example below is tagged with the cell(s) it covers.

Cell What makes it distinct Covered by
A. Positive score , so , predict class 1 Ex 1
B. Negative score , so , predict class 0 Ex 2
C. The exact centre , so — a tie, the boundary itself Ex 3
D. Far tails / saturation large, or , gradient nearly dies Ex 4
E. Degenerate zero weights : model ignores input, always outputs Ex 5
F. Gradient step, over-confident wrong learning nudges weights, sign of Ex 6
G. Real-world word problem translate words → features → probability → decision Ex 7
H. Log-odds / odds reading interpret as additive evidence Ex 8
I. Exam twist — 2-D boundary draw the line in feature space Ex 9
J. Symmetry check used to save work Ex 10

Let us anchor the whole page in one picture of the slide, marking where each cell lives on it.

Figure — Logistic regression and the sigmoid function

Read the figure: the centre (cell C) sits at ; walk right into positive (cell A, blue region, ); walk left into negative (cell B, red region); go far either way (cell D) and the curve flattens — the slope dies. That flattening is why the tails matter.


The worked examples

Figure — Logistic regression and the sigmoid function

Connections