CAB212 · Unit 3: Classification
Logistic regression and the sigmoid
8 practice questions
Key points
- Sigmoid maps scores to probabilities
- z = 0 -> p = 0.5
- Trained with log loss
- Linear decision boundary
Despite its name, logistic regression is a classification model. It computes a linear score z = w.x + b and squashes it with the sigmoid:
p = 1 / (1 + e^-z), giving a probability in (0, 1).
- z = 0 gives p = 0.5, the default decision boundary (threshold 0.5).
- z = ln 3 gives p = 0.75; large positive z gives p near 1.
- The decision boundary w.x + b = 0 is linear.
It is trained by minimising log loss (binary cross-entropy): L = -[y log p + (1 - y) log(1 - p)], usually with gradient descent. Odds = p / (1 - p) and log-odds = z, so each weight is a change in log-odds per unit of the feature.
For more than two classes use softmax (multinomial) or one-vs-rest. Regularization (L1/L2) is applied the same way as in linear regression.
Exam pitfall: MSE is not the standard loss for logistic regression; log loss is, because it is convex for this model.
Try two questions
The quantity modelled linearly by logistic regression is the:
- Distance to centroid
- Probability directly
- Squared error
- Log-odds
Show the answer
D. log(p/(1-p)) = w.x + b.
Logistic regression is used mainly for:
- Clustering
- Time-series smoothing only
- Classification
- Dimensionality reduction
Show the answer
C. It outputs class probabilities.