Logistic Regression
Logistic regression models binary outcomes with the sigmoid curve, log-odds, and maximum likelihood — including pseudo R-squared and the Wald test.
4 min read · Updated August 8, 2026
Logistic regression predicts the probability of an outcome that can take only two values — default or not, churn or not, disease or not — from any mix of numerical and categorical predictors. Despite the name, it is a classification model, and it remains the default baseline for binary outcomes because its coefficients are directly interpretable.
Ordinary linear regression is the wrong tool here for two reasons: it can predict probabilities outside , and with a binary target the residuals are never normally distributed around the fitted line. Logistic regression fixes both by fitting a sigmoid instead of a line.
The sigmoid and the logit
The logistic curve squashes any real-valued score into the range 0 to 1:
The constant shifts the curve left and right; the slope controls its steepness.

Dividing through by gives a simple statement about the odds:
and taking the natural logarithm makes the relationship linear in the predictors. This is the logit (log-odds):
The coefficient is the change in log-odds per one-unit increase in ; exponentiated, is the odds ratio — the factor by which the odds multiply per unit of . The model extends to any number of predictors:
The decision boundary sits where , i.e. where the logit equals 0 — a linear surface in the predictors, just like LDA.
Fitting: maximum likelihood
Where linear regression minimizes squared error, logistic regression chooses coefficients by maximum likelihood estimation (MLE): find the values that maximize the probability of observing the actual outcomes. The log-likelihood is
and it is maximized iteratively (the optimizer repeats until stops improving). Three diagnostics then assess the fit:
-
Pseudo . Several measures mimic for logistic models, but they disagree with each other and can’t be read like :
Measure Idea Efron’s Squared residuals summed and divided by total variability in the target McFadden’s — improvement of the full model over an intercept-only model Count Fraction of records correctly predicted at a 0.5 cutoff — plain accuracy -
Likelihood ratio test. Compares the full model against a restricted (e.g. intercept-only) model: follows a distribution with degrees of freedom equal to the difference in parameter counts. It answers “does the model as a whole beat the baseline?”
-
Wald test. Tests each coefficient individually: is approximately normal, and is with one degree of freedom. It answers “does this predictor contribute?”
Worked example: interpreting coefficients
Fitting the bank default data (predictors DAYSDELQ and BUSAGE, target DEFAULT) yields coefficients of roughly for DAYSDELQ and for BUSAGE. Interpretation via odds ratios:
- One more delinquent day multiplies the odds of default by — about an 11% increase in the odds, all else fixed.
- One more month in business multiplies the odds by — about a 0.8% increase.
Signs, magnitudes, and odds ratios make logistic models uniquely easy to explain to non-technical stakeholders — a major reason the method endures.
In practice
sklearn.linear_model.LogisticRegression is the standard implementation; use LogisticRegressionCV to tune the regularization strength by cross-validation. Standardize numeric predictors (StandardScaler in a Pipeline) so coefficients are comparable and regularization treats them fairly. The model’s predicted probabilities are usually well calibrated out of the box, which makes it the reference point when evaluating probability-producing classifiers like naive Bayes. For high-dimensional sparse data (text), L1-penalized logistic regression doubles as a feature selector.
Common pitfalls
- Reading as a probability change. It is an odds multiplier, not a percentage-point shift in probability — the effect on depends on the baseline.
- Perfect separation. If a predictor (or combination) separates the classes completely, MLE diverges and coefficients blow up; use penalization.
- Multicollinearity. Correlated predictors inflate standard errors and make Wald tests unreliable.
- Comparing pseudo variants. McFadden’s, Efron’s, and Count measure different things and can rank models differently — pick one and state which.
- Forcing a 0.5 cutoff. The threshold is a business decision; choose it with the confusion matrix and ROC analysis, not by default.
Summary
Logistic regression models the log-odds of a binary outcome as a linear function of the predictors, then maps that score back to a probability through the sigmoid. Coefficients are fit by maximum likelihood and read as odds ratios; overall fit is judged by likelihood-ratio tests and pseudo , individual predictors by the Wald test. It is interpretable, well calibrated, and still the baseline every fancier classifier must beat.