Skip to course content
Free Python statistics course

Statistical Data Analytics with Python

Module 10 Activity

Scenario

Model a binary outcome and report it in probabilities a reader can use.

What you build

A logistic regression with odds ratios, predicted probabilities and a justified threshold.

Steps

  1. Confirm the outcome is binary and check what a linear model would predict at the extremes of your predictor.
  2. Fit with smf.logit and verify the output reports log-likelihood and a z statistic.
  3. Exponentiate the coefficients and the bounds of conf_int(), label them as odds ratios, and give the baseline rate.
  4. Produce predicted probabilities with get_prediction(grid).summary_frame() so the intervals stay in [0, 1].
  5. Report the confusion matrix against the majority-class baseline and say how many positives were caught.
  6. Check calibration by binning predictions against observed rates, then choose a threshold from the relative cost of misses and false alarms.

Evidence to hand in

Review checklist