← Back to Classic ML Mind Map
中文·English
📊 Classic MLID: logistic-regression

Logistic Regression

逻辑回归 Log-Odds
🎯Core Definition
logistic regression models the log-odds as a linear function ln⁡p1−p=wTx+b\ln\frac{p}{1-p} = w^Tx + b, which inverts to the Sigmoid p=11+e−(wTx+b)∈[0,1]p = \frac{1}{1 + e^{-(w^Tx + b)}} \in [0,1]. Parameters come from MLE: the per-sample log-likelihood yln⁡p+(1−y)ln⁡(1−p)y\ln p + (1-y)\ln(1-p) negated is cross-entropy L=−∑i[yiln⁡pi+(1−yi)ln⁡(1−pi)]L = -\sum_i [y_i \ln p_i + (1-y_i)\ln(1-p_i)]. Differentiating w.r.t. z=wTx+bz = w^Tx + b using p′=p(1−p)p' = p(1-p) gives ∂L∂z=p−y\frac{\partial L}{\partial z} = p - y, hence ∂L∂w=(p−y)x\frac{\partial L}{\partial w} = (p - y)x; there is no closed form, so optimize by gradient descent / Newton (convex, unique global optimum).
💡Use Cases
the binary-classification baseline (CTR, credit risk, diagnosis); whiteboard staples include deriving Sigmoid from log-odds, deriving ∂L∂z=p−y\frac{\partial L}{\partial z} = p - y, and contrasting LR with SVM / naive Bayes.
⚡Key Problems Solved
fitting raw linear regression to probabilities yields illegal values outside [0,1][0,1] and is outlier-sensitive; LR guarantees valid probabilities, and the CE gradient p−yp - y decays only linearly as z→±∞z \to \pm\infty (never saturates), whereas squared loss 12(p−y)2\frac{1}{2}(p-y)^2 gives vanishing gradients near p→yp \to y — slow to train; adding λ2∥w∥2\frac{\lambda}{2}\Vert w\Vert^2 yields regularized LR for high-dimensional collinearity.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Logistic Regression.
Use Cases
In production engineering, what are the primary use cases for Logistic Regression and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Whiteboard: invert ln⁡p1−p=wTx+b\ln\frac{p}{1-p} = w^Tx + b into p=11+e−wTxp = \frac{1}{1+e^{-w^Tx}}, then derive ∂L∂z=p−y\frac{\partial L}{\partial z} = p - y via p′=p(1−p)p' = p(1-p) and the chain rule.
2
Why does LR use cross-entropy instead of squared loss? Explain the gradient saturation of squared loss as p→yp \to y.
3
Show MLE ≡ cross-entropy: derive the negative log-likelihood L=−∑i[yiln⁡pi+(1−yi)ln⁡(1−pi)]L = -\sum_i [y_i \ln p_i + (1-y_i)\ln(1-p_i)].
4
Compare LR vs SVM: hinge vs log loss, probabilistic output, support-vector dependence, and outlier robustness.
5
Why can't LR do multiclass directly? Contrast OvR vs Softmax extensions, and how class imbalance shifts the decision threshold.
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Logistic Regression"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice ➔
← Previous CardVIF MulticollinearityNext Card →Multiclass Strategies: OvR/OvO/Softmax

🔗 More Classic ML Knowledge Cards

AdaBoost DerivationBagging & Random ForestBaum-Welch (HMM EM)GBDT Negative Gradient