Logistic regression is a probabilistic classification model that computes the probability of a class label from input data. For multiple classes, it uses softmax to transform class scores into probabilities that sum to one; for binary classification, it uses a Bernoulli model and the logistic function. section 5.4 section 5.8
The training procedure follows these ideas:
- Compute posterior class probabilities using Bayes rule and class priors. section 5.4
- Represent multiclass scores with softmax, whose outputs form a probability distribution. section 5.4
- Maximize log likelihood, equivalently minimize negative log likelihood. section 5.4
- Update parameters with stochastic gradient descent using a learning-rate schedule satisfying Robbins–Monro conditions. section 5.4
Synthetic binary classification
A from-scratch Python implementation generates two-dimensional samples from two Gaussian clusters, assigns labels 1 and -1, trains with SGD, and visualizes both training cost and the resulting decision boundary.











