Logistic Regression
Logistic regression is a linear model for class probability, not a regression model for continuous targets. Compared with regression, it keeps the linear score but replaces squared error on with Bernoulli likelihood and cross-entropy on .
Defining math
For example with feature vector , the linear score and its sigmoid transform are
where is the intercept and the coefficient vector. The predicted probability of the positive class is
Fitting maximizes the Bernoulli likelihood, equivalently minimizing the negative log-likelihood
where is the label and the number of examples. Its gradient has a compact form,
where is the design matrix (one row per example), is the vector of predicted probabilities, and is the vector of labels — so is simply the vector of prediction errors.
Most practical fits add regularization, for example , because high-dimensional or nearly separable data can drive coefficients to unstable values.
Intuition
A coefficient is an additive effect on log-odds: increasing feature by one unit changes by , holding other features fixed. The sigmoid then maps any score to . This makes logistic regression a natural baseline when classification decisions need probabilities, thresholds, and calibration, not just labels.
Worked example
Suppose a fitted model has intercept and a single coefficient , so the score is . Take an example with :
The model assigns an 80% probability to the positive class. The coefficient acts on the log-odds: because , increasing by one unit adds to , which multiplies the odds by . At the odds are ; at they become , i.e. .
The sigmoid turns any score into a probability, and a threshold (often , i.e. ) turns the probability into a label:
Because the decision boundary is the line , moving the threshold slides it left or right, trading false positives against false negatives — a trade best reported with evaluation metrics rather than accuracy alone.
Caveats
Perfectly separable data makes the maximum-likelihood coefficients diverge; regularization gives a finite solution. A linear log-odds assumption can be wrong even when accuracy is acceptable, so inspect calibration curves and segment-level errors. Coefficients are not causal effects unless the data-generating and adjustment assumptions support that interpretation.
References
Nav