SDE & MLE Prep

Linear & Logistic Regression

Q: Derive the loss for logistic regression. Why not MSE?

  • Linear regression: ŷ = Xw + b, minimize MSE; closed form w = (XᵀX)⁻¹Xᵀy (use GD or regularize when XᵀX is ill-conditioned). Assumes linearity, independent errors, homoscedasticity.
  • Logistic regression: p = σ(w·x + b), σ(z) = 1/(1+e^{−z}). Maximizing the Bernoulli likelihood ⇒ minimize binary cross-entropy: L = −[y log p + (1−y) log(1−p)], with gradient ∂L/∂w = (p − y)·x (same elegant form as linear regression).
  • Why not MSE with a sigmoid: the loss becomes non-convex and gradients vanish when the prediction is confidently wrong.
  • Coefficients are interpretable as log-odds; multi-class → softmax regression.