Intuition What this page is for
The parent note gave you the machine: score z = w ⊤ x + b , squash with σ , read a probability, descend the cross-entropy loss. Here we drive that machine through every kind of input it can meet — positive and negative scores, the exact centre, the far tails, a zero-input degenerate case, a real word problem, and an exam twist. When you finish, no scenario should surprise you.
Before we start, one reminder of the three symbols we lean on, so nothing is used unearned:
Recall The three symbols, in plain words
z ::: the linear score , w ⊤ x + b . It is just a weighted sum of the inputs plus a constant. It can be any real number, negative or positive.
σ ( z ) ::: the sigmoid , 1 + e − z 1 . A squishy slide that turns any z into a number strictly between 0 and 1 — read as P ( y = 1 ∣ x ) .
p − y ::: 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.
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
z > 0 , so p > 0.5 , predict class 1
Ex 1
B. Negative score
z < 0 , so p < 0.5 , predict class 0
Ex 2
C. The exact centre
z = 0 , so p = 0.5 — a tie, the boundary itself
Ex 3
D. Far tails / saturation
∣ z ∣ large, p → 0 or 1 , gradient nearly dies
Ex 4
E. Degenerate zero weights
w = 0 : model ignores input, always outputs 0.5
Ex 5
F. Gradient step, over-confident wrong
learning nudges weights, sign of ( p − y )
Ex 6
G. Real-world word problem
translate words → features → probability → decision
Ex 7
H. Log-odds / odds reading
interpret z as additive evidence
Ex 8
I. Exam twist — 2-D boundary
draw the line w ⊤ x + b = 0 in feature space
Ex 9
J. Symmetry check
σ ( − z ) = 1 − σ ( z ) 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.
Read the figure: the centre (cell C) sits at z = 0 , p = 0.5 ; walk right into positive z (cell A, blue region, p > 0.5 ); walk left into negative z (cell B, red region); go far either way (cell D) and the curve flattens — the slope dies. That flattening is why the tails matter.
Worked example Example 1 — Cell A: positive score, predict class 1
Model z = 2 x − 4 (so w = 2 , b = − 4 ). Predict for x = 3 .
Forecast: Guess now — is p above or below 0.5 ? Roughly what value?
Compute the score. z = 2 ( 3 ) − 4 = 2 .
Why this step? The sigmoid only ever eats z ; nothing happens until we form the linear score.
Squash it. σ ( 2 ) = 1 + e − 2 1 = 1 + 0.1353 1 ≈ 0.881 .
Why this step? z = 2 is meaningless as a probability; the slide converts it to ( 0 , 1 ) .
Decide. 0.881 ≥ 0.5 ⇒ predict class 1 , 88% confident.
Why this step? The rule is "class 1 when p ≥ 0.5 ", equivalently "when z ≥ 0 ".
Verify: z = 2 > 0 , and we know σ > 0.5 exactly when z > 0 — consistent. Boundary at z = 0 ⇒ x = 2 ; since 3 > 2 we are on the class-1 side. ✓
Worked example Example 2 — Cell B: negative score, predict class 0
Same model z = 2 x − 4 . Now predict for x = 0.5 .
Forecast: Left of the boundary x = 2 ? Then predict which class?
Score. z = 2 ( 0.5 ) − 4 = − 3 .
Why this step? Same first move — always form z first.
Squash. σ ( − 3 ) = 1 + e 3 1 = 1 + 20.09 1 ≈ 0.0474 .
Why this step? Negative z lands in the lower half of the slide.
Decide. 0.0474 < 0.5 ⇒ predict class 0 , and quite confidently (only 4.7% chance of class 1).
Verify: x = 0.5 < 2 , so we are left of the boundary — class 0 as expected. Cross-check with symmetry: σ ( − 3 ) = 1 − σ ( 3 ) = 1 − 0.9526 = 0.0474 . ✓
Worked example Example 3 — Cell C: the exact centre (tie on the boundary)
Same model. Predict for x = 2 exactly.
Forecast: What does the machine say when it sits on the fence?
Score. z = 2 ( 2 ) − 4 = 0 .
Why this step? x = 2 is precisely the boundary point we found earlier.
Squash. σ ( 0 ) = 1 + e 0 1 = 2 1 = 0.5 .
Why this step? e 0 = 1 , so the fraction is exactly a half — a genuine coin-flip.
Decide. By the convention "p ≥ 0.5 ⇒ class 1", we call it class 1, but with zero real evidence — this is a tie, not a confident answer.
Verify: The centre of a symmetric S-curve is its half-height, so σ ( 0 ) = 0.5 is forced. ✓
Worked example Example 4 — Cell D: far tails and the dying gradient
Same model. Predict for x = 100 , and inspect the slope of the slide there.
Forecast: Will p be near 1? And will the model still want to learn there?
Score. z = 2 ( 100 ) − 4 = 196 .
Why this step? A huge input pushes z far into the positive tail.
Squash. σ ( 196 ) = 1 + e − 196 1 ≈ 1 (differs from 1 by about e − 196 ≈ 1 0 − 85 ).
Why this step? e − 196 is astronomically tiny, so p is essentially 1 — total confidence.
Slope there. Using σ ′ ( z ) = σ ( z ) ( 1 − σ ( z )) ≈ 1 ⋅ 1 0 − 85 .
Why this step? The gradient of the loss carries a factor tied to how far p can still move. In the tail the slide is flat, so σ ′ → 0 : the machine barely responds. This is why a very wrong, very confident prediction under squared error stalls — cross-entropy fixes it because its error term is ( p − y ) , which stays O ( 1 ) .
Verify: σ ′ ( z ) is maximal at z = 0 (value 0.25 ) and decays symmetrically; at ∣ z ∣ = 196 it must be near 0. ✓
Worked example Example 5 — Cell E: degenerate zero weights
Model w = ( 0 , 0 ) , b = 0 . Predict for any input, e.g. x = ( 7 , − 3 ) .
Forecast: If every weight is zero, what can the output possibly depend on?
Score. z = 0 ⋅ 7 + 0 ⋅ ( − 3 ) + 0 = 0 .
Why this step? With all weights zero the input is annihilated; only the bias would survive, and it is zero too.
Squash. σ ( 0 ) = 0.5 .
Why this step? A neutral, uninformative model outputs a flat 0.5 for every point.
Interpret. This is the correct starting state before training: "I have no idea." Learning then bends this flat surface.
Verify: Change the input to x = ( − 100 , 42 ) : still z = 0 , still p = 0.5 . The output is independent of x — exactly what zero weights must give. ✓
Worked example Example 6 — Cell F: one gradient step (over-confident, wrong)
Two features, w = ( 0 , 0 ) , b = 0 , α = 0.5 . Data point x = ( 1 , 2 ) , y = 1 .
Forecast: We under-predict a positive. Which way do the weights move — up or down?
Predict. z = 0 ⇒ p = σ ( 0 ) = 0.5 .
Why this step? Establish the current guess before scoring the mistake.
Error signal. p − y = 0.5 − 1 = − 0.5 .
Why this step? Negative error means we guessed too low for a true positive — push z up.
Per-weight gradient. ∂ J / ∂ w 1 = ( p − y ) x 1 = ( − 0.5 ) ( 1 ) = − 0.5 ; ∂ J / ∂ w 2 = ( − 0.5 ) ( 2 ) = − 1 .
Why this step? Gradient is (pred−target)×input; a larger input feels a larger nudge.
Update w ← w − α grad : w 1 ← 0 − 0.5 ( − 0.5 ) = 0.25 ; w 2 ← 0 − 0.5 ( − 1 ) = 0.5 .
Why this step? Subtracting a negative gradient raises the weight — next time z will be higher for this point.
Verify: Recompute the new score for the same point: z = 0.25 ( 1 ) + 0.5 ( 2 ) = 1.25 , so p = σ ( 1.25 ) ≈ 0.777 > 0.5 — we now correctly lean class 1. The step helped. ✓
Worked example Example 7 — Cell G: real-world word problem
A clinic uses z = 0.08 ( age ) + 1.5 ( tumor size in cm ) − 6 to model P ( malignant ) . A patient is age 50 with a 2 cm tumor. Malignant?
Forecast: Guess whether this crosses 50% before computing.
Assemble the score. z = 0.08 ( 50 ) + 1.5 ( 2 ) − 6 = 4 + 3 − 6 = 1 .
Why this step? Each feature contributes its weight × value; the bias − 6 is the baseline evidence with no features.
Squash. σ ( 1 ) = 1 + e − 1 1 = 1 + 0.3679 1 ≈ 0.731 .
Why this step? Convert the evidence score into an actual probability the clinician can act on.
Decide + report. 0.731 ≥ 0.5 ⇒ flag malignant , 73% confidence — enough to warrant follow-up.
Why this step? Units check: age in years × (per-year weight), size in cm × (per-cm weight) — both dimensionless log-odds contributions, summing to a pure number, as σ requires.
Verify: z = 1 > 0 so p > 0.5 , consistent. If we drop tumor size to 0 cm, z = 0.08 ( 50 ) − 6 = − 2 , p = σ ( − 2 ) ≈ 0.119 — a small tumor sharply lowers the risk, as intuition demands. ✓
Worked example Example 8 — Cell H: reading log-odds and odds
A model outputs z = w ⊤ x + b = 1.1 for an example. State the odds and the probability, and interpret.
Forecast: Odds and probability are different numbers — which is bigger here?
Odds. 1 − p p = e z = e 1.1 ≈ 3.004 .
Why this step? The parent derivation set ln 1 − p p = z , so exponentiating recovers the odds directly.
Probability. p = 1 + e z e z = 4.004 3.004 ≈ 0.750 .
Why this step? Convert odds "3 to 1" into a fraction of the whole: 3/ ( 3 + 1 ) .
Interpret. Class 1 is about 3× more likely than class 0. Add one unit to a feature with weight 0.5 and the log-odds rise by 0.5 , multiplying the odds by e 0.5 ≈ 1.65 — evidence stacks additively on the log-odds scale.
Verify: Round-trip: σ ( 1.1 ) = 1/ ( 1 + e − 1.1 ) = 1/ ( 1 + 0.3329 ) ≈ 0.750 matches step 2. ✓
Worked example Example 9 — Cell I (exam twist): draw the 2-D decision boundary
Model z = x 1 + 2 x 2 − 4 . Where is the boundary, and which side is class 1?
Forecast: Is the boundary a curve or a straight line? Sketch it in your head first.
Set the boundary condition. Boundary is p = 0.5 ⟺ z = 0 ⟺ x 1 + 2 x 2 − 4 = 0 .
Why this step? σ crosses 0.5 exactly at z = 0 ; the boundary lives entirely in the z = 0 locus.
Rewrite as a line. x 2 = 2 4 − x 1 = 2 − 2 1 x 1 — a straight line, slope − 2 1 , intercept 2 .
Why this step? Solving for x 2 shows it is linear in x 1 ; the sigmoid never bends feature space.
Pick the class-1 side. Test the origin ( 0 , 0 ) : z = − 4 < 0 ⇒ p < 0.5 , so the origin is class 0. The class-1 half-plane is the other side (larger x 1 + 2 x 2 ).
Why this step? One test point orients the whole half-plane.
Verify: Point ( 4 , 2 ) : z = 4 + 4 − 4 = 4 > 0 , class 1 — and indeed it lies above the line. Point ( 0 , 0 ) : class 0. See the figure. ✓
Worked example Example 10 — Cell J: symmetry shortcut
You already know σ ( 2 ) ≈ 0.881 from Example 1. Find σ ( − 2 ) without a calculator.
Forecast: Should σ ( − 2 ) be above or below 0.5 ?
Invoke symmetry. The parent property: σ ( − z ) = 1 − σ ( z ) .
Why this step? It saves the whole exponential — reflect the known value instead.
Apply. σ ( − 2 ) = 1 − σ ( 2 ) = 1 − 0.881 = 0.119 .
Why this step? Negating the score mirrors the probability about 0.5 .
Verify: Direct: σ ( − 2 ) = 1/ ( 1 + e 2 ) = 1/ ( 1 + 7.389 ) ≈ 0.119 — matches. And σ ( 2 ) + σ ( − 2 ) = 0.881 + 0.119 = 1.000 . ✓
Mnemonic Scenario reflexes
Sign of z tells the class: z > 0 → class 1, z < 0 → class 0, z = 0 → tie.
Tails kill the slope (σ ′ → 0 ) — that is why we use cross-entropy, not MSE.
Zero weights ⇒ flat 0.5 — the honest "I don't know" start.
Boundary is always straight — solve z = 0 , test one point to orient.
Mirror trick: σ ( − z ) = 1 − σ ( z ) .