It is linear, then squashed
Linear regression can output 4.7 or minus 12, and neither is a probability. Logistic regression puts the linear score through a function that lands in the unit interval.
- : the raw linear score, called the logit.
- : the logistic sigmoid.
At the output is exactly 0.5. Large positive approaches 1, large negative approaches 0, and it never reaches either.
What the weights actually mean
Invert the sigmoid and the linear part reappears, applied to something specific.
The left side is the log-odds. So logistic regression is a linear model of the log-odds, not of the probability.
That means a weight of 0.7 multiplies the odds by for each unit of that feature: a constant multiplicative effect, not a constant additive one.
The loss, and why not squared error
This is binary cross-entropy. Squared error on top of a sigmoid gives a non-convex loss with flat regions where the gradient vanishes, and training stalls there.
Cross-entropy composed with the sigmoid is convex, and its gradient is famously clean.
Prediction minus target, times the input. Identical in form to linear regression's gradient, which is not a coincidence. Both are generalised linear models.
One prediction, in order
- Take the dot product of the weights with the features and add the bias.
- Push that scalar through the sigmoid.
- Read the result as the probability of the positive class.
- Compare it to a threshold to get a decision.
- Choose that threshold from the cost of each error, not by defaulting to 0.5.
Why it is still worth knowing
It is the last layer of almost every classifier ever built, including every neural network that ends in a sigmoid or a softmax.
Understanding it is understanding what that final layer is doing, and why its output can be read as a probability at all.