Chapter 39 — Key Takeaways
Key Takeaways
- You built a real system. Crease is 36 modules, 617 public functions and classes (99.2% documented) and 14,969 lines of code, one module per chapter, with an import graph that only points backwards.
- Keep the dashboard in three layers. Cached data and model functions; figure builders; page layouts. The page holds no analysis, so the same numbers and figures can be produced by scripts and tests without a browser.
- Nothing sees its own future. Every model on the dashboard is fitted on matches before the one it shows: win probability by season, the pre-match predictor by date, the live simulator by season start. Women's matches get women's models.
- One match runs through six calls. IPL 2026 final: data and scorecard → SR+ context → WP v1 curve (Bengaluru 0.865 at the innings break) → turning points and WPA (Rasikh Salam +0.112, the most) → pre-match 0.571 for Gujarat (announced sheets, home) → live projection 164 (135–195) after 10 overs; real total 155.
- Different models, different evidence, different answers. The pre-match model favoured Gujarat; WP v1 favoured Bengaluru at the first ball. Explain the gap (Elo system, home term, team sheets) rather than choosing the number you like.
- Every model needs a card with both halves. Out-of-time accuracy against a naive baseline, and the failure modes. Re-tested on 2026, four of five models beat their baselines; the IPL pre-match model did not (0.7% worse than a coin), as Chapter 24 predicted.
- Test what you built. 37 smoke tests in about three seconds; ten headless page runs; and reproduction tests against the book's settled numbers.
Metrics & Formulas
| Term | Definition | Chapter 39 value |
|---|---|---|
| WPA | Σ change in batting side's WP over the balls a player faced (bowlers: sign flipped) | Rasikh Salam +0.112; Kohli +0.073 (IPL 2026 final) |
| Brier skill score | 1 − Brier(model) ÷ Brier(baseline) | WP v1 on 2026 men's T20 chases: 1 − 0.1062/0.2500 = 0.575 |
| Calibration slope | Coefficient from regressing outcomes on logit(forecast); 1 = calibrated | WP v1, 2026: 0.99 overall, 1.33 IPL |
| 80% projection range | 10th–90th percentile of simulated totals | IPL 2026 coverage: 84.5% / 81.7% / 69.0% after 6 / 10 / 15 overs |
| Shrunk matchup SR | expected + n/(n + k) × (raw − expected), k = 303 balls | de Kock v off-spin 115.5 (108.5–122.4) v expected 125.8 |
| Log score (tournament) | ln P(real champion) | Bengaluru, IPL 2026 eve: −1.873 v −2.303 for 1 in 10 |
| Improvement over baseline | (baseline − model) ÷ baseline | Live after 10 overs +30.3%; SR+ projection +31.0% |
Common Mistakes (and the fix)
| Mistake | Fix |
|---|---|
| Fitting models inside the page function | Move them into cached layer-1 functions keyed by simple arguments |
st.cache_data on a fitted model |
st.cache_resource for models and large read-only tables |
Mutating a cached predictor (Predictor.update) |
Build a fresh predictor; never change what cache_resource returns |
build_predictor("ipl", ...) with no model= |
Pass fit_pooled_t20(as_of); the IPL-only logit has a negative Elo weight |
| Using the men's WP model for a women's match | One model per gender; Case Study 1 shows a 10-point error at the innings break |
| Quoting a raw matchup | Quote the shrunk value with its interval and the expected value beside it |
| Smoke tests that only check "no crash" | Assert a cricket fact (the final's total was 155; 34.3 overs = 207 balls) |
| Model cards with only accuracy | Add failure modes and "do not use for" |
| Calling rendered figures screenshots | Say how a figure was made |
Decision Framework: before you trust a number on a dashboard
- When was the model fitted? Only on matches before this one?
- Whose model is it? Right gender, right competition pool, right era?
- Is there a range or a sample size? Shrunk, not raw? Interval shown?
- What does the model card say? Which baseline does it beat out of time, by how much, and does a listed failure mode apply here (last ball, IPL pre-match, late-innings ranges, wickets)?
- Do the tests pass? Smoke tests green, and the system still reproduces the settled numbers?
- Would two models disagree? If so, name the assumption that drives the difference.