5.6.2 · D1Machine Learning (Aerospace Applications)

Foundations — Logistic regression — sigmoid, cross-entropy loss

2,085 words9 min readBack to topic

Before you can read a single line of the parent topic, you need to already own about a dozen small tools. This page builds every one of them from nothing. Read top to bottom — each tool is used by the next.


0. What "classification" even means

The picture: imagine sorting parts on a conveyor belt into two bins. There is no "1.5 bin". Contrast this with predicting altitude (a continuous number) — that would be regression, the job of Linear Regression. Logistic regression is the classification cousin.

Why the topic needs it: the entire machine is built to output a number we can compare against a label that is only ever 0 or 1.


1. Numbers, variables, and subscripts

Let us fix the alphabet the parent uses, because it hides real meaning in tiny letters.

The picture: think of your dataset as a spreadsheet. Rows are examples (superscript ). Columns are features (subscript ). One cell is .


2. Vectors and the dot product

The parent jumps straight to . Let us earn it.

The picture below shows a 2-feature example as an arrow in a plane, and shows a weight vector living in the same space.

Figure — Logistic regression — sigmoid, cross-entropy loss

Why this tool and not another? We need one single number that summarizes all features into a "confidence score." The dot product is the simplest way to blend many inputs into one, with a tunable knob () per input. That single number gets its own name:


3. The exponential — the bending tool

Figure — Logistic regression — sigmoid, cross-entropy loss

Why does the topic need specifically? We want a knob that:

  • is never negative (probabilities can't come from negative denominators),
  • smoothly connects "very small" to "very large" as sweeps the number line.

does exactly this: when is large, ; when is very negative, . Look at the amber curve — that behaviour is what the sigmoid rides on.


4. Putting it together: the sigmoid shape

Now the parent's headline formula is readable. You already know every piece: is the raw score, is the always-positive bending tool, and dividing 1 by "1 + something positive" forces the answer into .

Figure — Logistic regression — sigmoid, cross-entropy loss
  • When huge positive: , so .
  • When : , so — the decision boundary (the cyan cross in the figure).
  • When huge negative: huge, so .

Why we care about the smooth S-shape and not a hard step at 0: Gradient Descent needs a slope everywhere to know which way to nudge the weights. A vertical cliff has no usable slope. The gentle S has one at every point.


5. Odds, probability, and the logarithm

The parent derives sigmoid starting from "odds." Two more tools.

The picture: probability is a slider from 0 to 1; odds stretch that same slider out to run from 0 to .

That last property is exactly why the parent takes a of the likelihood (a big product) — it becomes a friendly sum. The "log-odds" stretches probability across the entire number line, which is why it can equal the unbounded score .


6. Derivatives — the "which way is downhill" tool

The picture: stand on a hillside (the loss surface). The derivative is the arrow pointing straight downhill under your feet. Gradient Descent just repeatedly steps in the opposite direction of that arrow to reach the valley floor (the minimum loss).

Why the topic needs derivatives at all: without a slope there is no way to know how to change and to make the loss smaller. Training is slope-following.


7. The cost/loss symbols and

The picture: is the height of the landscape Gradient Descent walks down; every training step lowers it. This connects to Maximum Likelihood Estimation — minimizing cross-entropy is exactly the same as choosing weights that make the observed labels most likely.


8. The learning rate

The picture: is your stride length walking downhill. Too big and you leap across the valley and bounce; too small and you crawl forever. The parent chooses a tiny precisely because unnormalized features make the slope huge.


How it all feeds the topic

features x and labels y

logit z = wx + b

weights w and bias b

dot product

exponential e to the -z

sigmoid squashes z into 0 to 1

prediction y-hat

log and probability odds

cross-entropy loss L

cost J averaged over N

derivative and chain rule

gradient of J

gradient descent updates w and b

learning rate alpha

Read it as a loop: features and weights make ; the sigmoid turns into ; comparing with gives loss ; derivatives give the downhill direction; gradient descent updates the weights; repeat.


Equipment checklist

Cover the right side and answer out loud. If any one stumps you, re-read its section above.

What does mean and what range does it live in?
The model's estimated probability of class 1; it lives strictly between 0 and 1.
In , what do the subscript and superscript each mean?
Subscript = which feature (column); superscript = which example (row). The parentheses mean it is NOT a power.
What single number does produce, and what is it called?
One raw confidence score , called the logit; it can be any real number.
Why is chosen for the sigmoid instead of some other function?
Because it is always positive and smoothly runs from near 0 (large ) to huge (very negative ), letting stay inside .
What is and why does that value matter?
— it is the decision boundary between predicting class 0 and class 1.
State the odds of an event with probability .
, i.e. 4-to-1.
What does taking a logarithm do to a product, and why is that useful here?
It turns a product into a sum, converting the messy likelihood product into an easy-to-optimize sum.
In plain words, what does a derivative tell you?
The slope: how much the cost changes if you nudge a little, and in which direction — the downhill signal for gradient descent.
Difference between and ?
is the loss on one example; is the average loss over all examples — the quantity we actually minimize.
What role does play and what goes wrong if it is too large?
It is the step size in gradient descent; too large and the updates overshoot and bounce instead of settling into the minimum.