Logistic Regression
Modelling the probability of a binary outcome using the sigmoid function â fitting by maximum likelihood or gradient descent.
Logistic regression predicts the probability that a binary outcome () is 1, given features .
The model applies the sigmoid function to a linear combination of features:
The sigmoid squashes any real number into , making the output interpretable as a probability.
A decision boundary is drawn where , i.e., where .
- Output is always strictly between 0 and 1 â never exactly 0 or 1, no matter how extreme the input
- The decision boundary is always linear (a hyperplane) in the original feature space
- Log-odds (logit) are linear in the features, even though probability itself is not
- Fits via maximizing likelihood â there's no closed-form solution, unlike ordinary linear regression
- Using MSE instead of cross-entropy as the loss: MSE with a sigmoid output produces a non-convex loss landscape, making optimization unreliable â cross-entropy is convex and the standard choice
- Treating the linear decision boundary as a fixed limitation: feature engineering (polynomial terms, interactions) can let logistic regression fit curved boundaries despite the model itself being linear in its inputs
Features: = number of exclamation marks, = contains "FREE" (0/1). Learned weights: , , .
For an email with 2 exclamation marks and "FREE": . . Likely spam.
If the sigmoid outputs 0.72, what class would logistic regression predict (using threshold 0.5)? What is the log-odds?
Solution
Class 1 (since ).
Log-odds = .
Logistic regression models log-odds as a linear function of features â the "logit" transformation.
Related concepts
Needs first