Logistic Regression and Probability Estimation
Logistic Regression is a classifier that computes a weighted sum of inputs and maps the output to a probability between and .
Probabilistic Formulation: The Sigmoid Function
The model feeds its linear output into the Sigmoid Function :
The prediction rule for binary classes is:
The prediction decision boundary is linear where .
Parameter Optimization: Log Loss
To optimize parameters , we minimize the convex Log Loss (binary cross-entropy):
It penalizes confident incorrect predictions with infinite cost (if and , then ).
Multiclass Classification Strategies
While Logistic Regression is inherently a binary classifier, it can be extended to handle multiple classes (e.g., classifying images of digits 0-9) using specific strategies:
- One-vs-Rest (OVR) (also called One-vs-All): Trains separate binary classifiers for an -class problem. Each classifier is trained to distinguish one specific class from all the rest combined. During prediction, the classifier that outputs the highest probability wins. This is the default approach in most ML libraries for logistic regression.
- One-vs-One (OVO): Trains a binary classifier for every possible pair of classes, resulting in classifiers. For a new data point, all classifiers are run, and the class that wins the most duels is selected. OVO is particularly useful for algorithms that scale poorly with dataset size (like SVMs), because each classifier is only trained on the subset of data belonging to the two classes.
Alternatively, Softmax Regression (Multinomial Logistic Regression) generalizes Logistic Regression to natively support multiple classes by normalizing raw logits into a direct probability distribution across all classes without training multiple binary models.
Example: Logistic Regression Inference
The following example demonstrates calculating predictions using a trained Logistic Regression classifier:
Interactive Lab
Perform logistic regression inference. Calculate the predicted class and class probabilities for a sample point near the decision boundary.
Exercise
Test your knowledge of the Logistic Regression model boundary behavior: