A worked model answer

The ML capstone, worked: beating the baseline honestly

The Machine Learning from Scratch capstone asks one loaded question: can two models you built from scratch genuinely beat always-pick-home? The first worked capstone ended in a deliberately uncomfortable verdict. This one ends in a clean yes — and the point is knowing exactly what earned it.

The setup

Data: the bundled 2023-24 game log (1,230 games; the In-Season-Tournament final is excluded because it doesn't count in standings) and final net ratings. One feature only — the net-rating gap between home and away — because the capstone grades discipline, not feature count. The baseline to beat: always pick the home team, which wins 54.3% of games all by itself. Both challengers are pure-numpy builds from the course: logistic regression (gradient descent, part 3) and k-nearest-neighbors (k=25, part 7), evaluated with the course's own 5-fold cross-validation and ROC code (parts 5 and 6). Seed 2026; every number below is printed by build/make_capstone2_chart.py.

The result

Two-panel chart. Left: pooled cross-validated ROC curves - logistic regression at AUC 0.752, k-NN at 0.731, both far above the diagonal always-pick-home line at 0.500. Right: five-fold accuracy bars - baseline 54.3%, logistic 67.7%, k-NN 67.2%.
Cross-validated ROC and accuracy for both from-scratch models against the baseline. Data: nba_home_results.csv + nba_ratings.csv; script: build/make_capstone2_chart.py.

Logistic regression: 67.7% accuracy (five folds: 64.6 to 69.9), pooled AUC 0.752. k-NN: 67.2%, AUC 0.731. The baseline: 54.3%, AUC 0.500 by construction. Both models beat the baseline in all five folds — not on average with excuses, but everywhere. The margin, +13 points of accuracy, is the honest size of what one good feature is worth in this problem.

Why this counts as beating it honestly

Three disciplines made the yes trustworthy, and skipping any of them is how capstones lie to their authors. The baseline was taken seriously: 54.3% is genuinely hard to beat with noise, and accuracy alone can flatter a model that just learned to say "home" — which is why the ROC panel matters (a model that parrots the baseline collapses to the diagonal). Every number is out-of-fold: the models never scored a game they trained on, so the 67.7% is an estimate of real predictive skill, not memory. And the two models agree: when a linear fit and a neighborhood vote extract nearly the same edge from the same feature, the edge belongs to the feature, not to either model's quirks. That last observation is the course's quiet thesis — most of applied machine learning is feature honesty wearing a model costume.

What the models actually learned

The full-data logistic fit lands at w = 0.133, b = 0.213: a dead-even matchup gives the home side 55.3% (the model rediscovered home-court advantage on its own), and a +5 net-rating edge pushes it to 70.7%. That is the entire learned worldview — two parameters — and it out-predicts the baseline by thirteen points. Meanwhile k-NN, with no formula at all, traces nearly the same curve by averaging neighborhoods. Both are implementations of the same sentence: better teams win more often, proportionally to how much better they are, plus a home nudge.

The ceiling, stated

Honesty section. Sixty-eight percent is nowhere near the ceiling for NBA prediction — and the gap isn't sloppiness, it's information: rest, injuries, lineups, and season-time (our ratings are final ratings, which quietly leaks end-of-season knowledge into early-season games) all live outside our one feature. That leakage inflates these numbers somewhat, and a stricter capstone would use ratings-to-date — noted here because a model answer that hides its own advantage isn't one. The submission checklist, then: a stated baseline, out-of-fold everything, at least two model families, ROC beside accuracy, and one paragraph naming what your features can't see. If your capstone concludes the baseline held — on a worse feature, say — the course brief means what it says: that's a publishable answer too.

Work one, and send it — the honest ones get answers.