Course map
Stage 1: Foundations
Stage 2: Machine Learning
Stage 3: Deep Learning
Stage 4: LLMs & Generative AI
Stage 5: Production & Specialization

Project

Stage 2 project: Churn model for a business team

Start after Part 8

Stage 2

Everything from Stage 2 in one deliverable: a tuned, cross-validated pipeline, a capacity-based threshold, and a summary a non-ML stakeholder can act on.

Time: ~3–4 hours if you build it yourself (recommended). Run the reference version: PYTHONPATH=tools .venv/bin/python stage-2-machine-learning/project-churn-model/churn_model.py

Core (build this)

  1. One leak-free ColumnTransformer pipeline (Part 5), shared by every candidate model.
  2. Tune at least two model families with GridSearchCV on training data only (Part 8).
  3. Pick the winner by cross-validated ROC-AUC; report its test ROC-AUC once.
  4. Turn probabilities into a call list sized to the team's capacity (Part 6).
  5. Print a three-line summary in business language — no metric jargon without translation.

Stretch

  • Add permutation feature importance and a per-contract fairness check (Part 8's FNR table).
  • Add calibration (CalibratedClassifierCV) and verify predicted probabilities match observed rates.

Production level

  • Write a model card: data used, metrics, limitations, intended use, groups checked.
  • Save the fitted pipeline with metadata (versions, metrics) — Track B picks this up.

What "done" looks like

Output of the reference run:

logistic regression  CV ROC-AUC 0.806  {'clf__C': 10.0}
gradient boosting    CV ROC-AUC 0.794  {'clf__learning_rate': 0.05, 'clf__max_depth': 2}

chosen model: logistic regression (test ROC-AUC 0.811)
call-list threshold for 100 calls: 0.481

SUMMARY FOR THE RETENTION TEAM
- Each month we send you the 100 customers most likely to churn.
- About 59% of them are genuine churn risks; the list covers 49% of all churners.
- The model leans on contract type, tenure and support calls; customers on
  month-to-month contracts with recent support calls are the highest risk.

Search the guide