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

Project

Stage 1 project: Churn predictor from scratch

Start after Part 4

Stage 1

Everything from Stage 1 in one small program: load the churn data, clean it without leakage, train logistic regression with gradient descent in plain NumPy, pick a threshold, and compare against the baseline.

Time: ~2–3 hours if you build it yourself (recommended). Run the reference version: PYTHONPATH=tools .venv/bin/python stage-1-foundations/project-churn-predictor/churn_predictor.py

Core (build this)

  1. Load make_churn(), split 80/20 stratified, impute missing charges with the train median.
  2. Standardize numeric features with train statistics; add the month-to-month flag.
  3. Train logistic regression with gradient descent (your Part 4 loop). Print the log loss every 500 steps — it must fall.
  4. Evaluate on the test set: accuracy at threshold 0.5, and the majority-class baseline next to it.
  5. Print the learned weights with their feature names, readable as risk factors.

Stretch

  • Add L2 regularization (loss + lambda * (w**2).sum()) and mini-batch updates; compare loss curves.
  • Write your own 5-fold cross-validation and report mean ± std accuracy.

Production level

  • Package it as a module with functions (load, preprocess, train, evaluate), a __main__ entry point, and pytest tests for the preprocessing (no missing values out; means ≈ 0).

What "done" looks like

  • A loss curve that falls and flattens.
  • Test accuracy clearly above the 0.70 baseline.
  • No statistic computed from test rows anywhere in the pipeline.

The reference implementation is churn_predictor.py; its output below came from a real run.

 step   log loss (train)
    1   0.6931
  500   0.4903
 1000   0.4847
 1500   0.4840
 2000   0.4839
test accuracy at 0.5: 0.762  |  baseline: 0.700
weights as risk factors:
  tenure_months        -0.67
  monthly_charges      +0.54
  support_calls        +0.47
  month_to_month       +1.75

Search the guide