SigmaAnalytics & Tech
F3PythonAdvancedAbout 180 min to complete

Logistic Regression (Statsmodels)

Every model so far predicted a number (a tip, a body mass). But many of the most important questions are yes/no: will this customer churn?

Notebook

About 180 minutes to complete

Enrol to read the notebook and download it to run.

What this module covers

Every model so far predicted a number (a tip, a body mass). But many of the most important questions are yes/no: will this customer churn?

By the end of it

  • Explain why linear regression fails for a binary outcome and how the sigmoid/logit fixes it
  • Understand odds, log-odds (logit), and interpret coefficients as odds ratios via exp(β)
  • Fit a logistic model with statsmodels (smf.logit) and read its summary
  • Produce predicted probabilities and turn them into class predictions with a threshold
  • Evaluate a classifier: confusion matrix, accuracy, precision, recall, F1, and the ROC curve / AUC
  • Handle multiple and categorical predictors, and read pseudo-R² and the likelihood-ratio test
  • Recognise the pitfalls: reading coefficients as probabilities, a bad threshold, and class imbalance