Data Mining & Visualization

Online B.Com · Sem 5

Lesson 2 of 5Analytics

Logistic Regression Explained

Data Mining & Visualization

About the video

StatQuest: Logistic Regression

StatQuest with Josh Starmer

Study notes

Logistic regression predicts the probability of a binary outcome by passing a linear combination of predictors through the sigmoid function. Coefficients are estimated by maximum likelihood and act on the log-odds. A threshold (often 0.5) converts probabilities into class labels.

Model

  • z = b0 + b1x1 + ... + bkxk
  • p = 1/(1+e^(-z)), which is always between 0 and 1.
  • Logit form: ln(p/(1-p)) = z, so the log-odds are linear in the predictors.
  • At z = 0, p = 0.5.

Interpreting coefficients

  • A one-unit increase in x_j changes the log-odds by b_j.
  • The odds are multiplied by e^(b_j) (the odds ratio).
  • A positive b means the probability increases with x; a negative b means it decreases.

Fitting and evaluation

  • Fitted by maximum likelihood, equivalently minimising log loss (cross-entropy), not least squares.
  • Classify as 1 if p >= threshold; changing the threshold trades sensitivity against specificity.
  • Evaluate with a confusion matrix, accuracy, precision, recall, and ROC curve with AUC.
  • Use it instead of linear regression for binary outcomes, because linear predictions can fall outside 0-1.

Key terms

Sigmoid
The function 1/(1+e^(-z)), which maps any real number to (0,1).
Odds
p/(1-p).
Logit
The log-odds, ln(p/(1-p)).
Odds ratio
e^b; the multiplicative change in odds per unit increase in x.
Maximum likelihood
The estimation method that chooses the parameters making the observed data most probable.

Takeaways

  • Logistic regression is linear in the log-odds and outputs a probability via the sigmoid.
  • e^b gives the odds ratio.
  • The threshold choice affects the error trade-off.
  • It is a classification method despite the name 'regression'.
Contribute

Was this lesson helpful?

We read every rating and fix the weakest lessons first.