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 lnp1p=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 ylnp+(1y)ln(1p)y\ln p + (1-y)\ln(1-p) negated is cross-entropy L=i[yilnpi+(1yi)ln(1pi)]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(1p)p' = p(1-p) gives Lz=py\frac{\partial L}{\partial z} = p - y, hence Lw=(py)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 Lz=py\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 pyp - y decays only linearly as z±z \to \pm\infty (never saturates), whereas squared loss 12(py)2\frac{1}{2}(p-y)^2 gives vanishing gradients near pyp \to y — slow to train; adding λ2w2\frac{\lambda}{2}\Vert w\Vert^2 yields regularized LR for high-dimensional collinearity.
🎯5 High-Frequency Exam Points
1
Whiteboard: invert lnp1p=wTx+b\ln\frac{p}{1-p} = w^Tx + b into p=11+ewTxp = \frac{1}{1+e^{-w^Tx}}, then derive Lz=py\frac{\partial L}{\partial z} = p - y via p=p(1p)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 pyp \to y.
3
Show MLE ≡ cross-entropy: derive the negative log-likelihood L=i[yilnpi+(1yi)ln(1pi)]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 CardMulticlass Strategies: OvR/OvO/Softmax

🔗 More Classic ML Knowledge Cards

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