Summary
Logistic regression models binary outcomes with affine log-odds, not an affine probability. Fit probabilities using a Bernoulli likelihood; choose actions separately using deployment costs.
Task: independent observations have , . Evaluate candidate intercept and slope using summed negative log-likelihood. Find both probabilities, the likelihood, and the intercept/slope gradient. These coefficients are a checked candidate, not an asserted finite optimum for separable data.
The maximum-likelihood lesson supplies the fitting principle; here the conditional observation model is Bernoulli.
The model
For binary :
The log-odds (logit) is linear in :
Odds are , with . Equal score increments multiply odds equally, but do not add equal probability increments.
Learning objective
Equal logit steps multiply odds rather than add fixed probability
Derivation
Does another unit logit step add the same probability near the upper end?
Training
Negative log-likelihood (binary cross-entropy):
Our scores give probabilities . The observed-label likelihood is , so . Residuals give
The negative gradient locally decreases the intercept and increases the slope. This is Bernoulli cross-entropy, not a Gaussian squared-error objective.
With augmented design matrix containing the intercept column, . Its Hessian is , positive semidefinite for fixed features. Convexity does not ensure a finite, identifiable minimizer. Evaluate each term stably as , with .
Change decision costs
New task: false positives cost ; false negatives cost ; correct actions cost zero. Keep the probabilities and compare positive-action cost with negative-action cost . Check: choose positive for ; at , costs are versus . Use when: these probabilities describe the deployment population and errors have unequal costs.
Change the feature basis
New task: represent XOR at . Add interaction ; candidate score gives . Check: threshold recovers all four classes. Use when: additive log-odds in original features misses a known interaction. The model remains linear in expanded coefficients; these are fixture coefficients, not an MLE claim.
Common pitfalls
Failure: for , , and , increasing drives loss toward zero. No finite attains it: complete separation defeats the implied finite optimum. A sigmoid does not establish calibration under finite samples, misspecification, regularization, or deployment shift.
Reconstruct: a coefficient doubles odds. Starting at , what follows one feature unit, holding others fixed?
Answer
Odds move from to , giving , not .
Multinomial / softmax regression
For mutually exclusive classes, normalize affine class scores with softmax and fit categorical cross-entropy. Multilabel outcomes instead need an appropriate joint or separate-output model; not every classifier uses softmax.
Properties
For an additive coefficient, is a conditional log-odds change holding other features fixed; is its odds ratio. Interactions alter that interpretation, and it is not automatically a causal effect. At probability threshold , the boundary is .
When to use vs. alternatives
Compare held-out probability quality, operating costs, latency, feature construction, and maintainability against relevant alternatives. Validate calibration separately; a model family is not a calibration certificate.
L-BFGS uses quasi-Newton updates; SGD/Adam use gradient updates; Newton-Raphson/IRLS uses curvature through weighted least squares. Solver choice depends on sparsity, dimensions, penalties, and resource limits.
An added is one declared L2 convention, not an automatic implementation default. State whether the intercept is penalized and scale features using training-only statistics. Control feature engineering and leakage when comparing trees or nonlinear models. Use the separate derivation for the Bernoulli gradient cancellation.