Is this email spam? Is this tumour malignant? Will this customer cancel? Binary classification asks for a yes or no, and ideally for a probability of yes, so that we can decide how cautious to be. Linear regression isn't suitable: its output is unbounded, so it can predict probabilities of 1.7 or −0.3, and a few extreme examples can tilt the whole line.
The sigmoid
Logistic regression keeps the weighted sum (called the logit) and passes it through the sigmoid (logistic) function, which squashes any real number into :
- : a logit of zero means a coin flip.
- Large positive gives probabilities near 1; large negative near 0.
- , and its derivative is neatly .
What the weights mean: log-odds
Invert the sigmoid and you find the logit is the log-odds of the positive class. So logistic regression is a linear model of log-odds: each unit increase in feature multiplies the odds by . Medical papers report exactly these numbers as odds ratios.
From probability to decision
To make a hard decision, compare the probability to a threshold, usually 0.5, which is the same as checking the sign of . But the threshold is a choice: a cancer screen might flag anything above 0.1 because missing a tumour costs far more than a follow-up test. Keeping the probability and choosing the threshold separately is one of the big advantages of probabilistic classifiers. You'll tune thresholds in module 3.
Logistic regression is a linear model of the log-odds, turned into a probability by the sigmoid. Thresholding that probability gives a decision, and the threshold is yours to choose.