Baselines and honest splits
A baseline sets the floor; an honest split keeps the ruler straight.
An ETA model improves RMSE while increasing missed-delivery cost.
This chapter moves from choose a hard-to-cheat baseline to tune once, test once. We will make the idea concrete in a small code example before placing it back inside a production system with a declared latency, cost, and operator-capacity budget.
Select features, hyperparameters, and threshold on validation; open the test only for the frozen candidate and baseline.
Verify the behavior illustrated in honest_split.py, then measure decision utility, slice reliability, and system latency.
ROC-AUC alone on 0.1% prevalence hides unusable precision and an impossible review queue. An unsafe release must degrade to a named baseline or the last known-good version.
Build the idea one layer at a time.
A sophisticated model is valuable only relative to a credible simple alternative, measured on data that was not used to invent either one.
Baselines expose whether complexity buys anything. For a binary event, the historical base rate is a probabilistic baseline; for forecasts, yesterday or last week may be stronger than a learned model that merely rediscovers seasonality.
The split must simulate deployment. Chronological validation places tuning before testing, and entity grouping prevents the same customer or device from teaching and grading the model. The final test remains sealed until the policy is fixed.
- censoring
- temporal splits
- PR curves
- calibration
Follow the reasoning before touching the code.
- 01
Choose a hard-to-cheat baseline
Use a rule, prior, or seasonal naive policy that is available at the same cutoff and serves the same decision.
- 02
Split like deployment
Place training before validation before test, and group correlated entities when future rows can reveal their identity.
- 03
Tune once, test once
Select features, hyperparameters, and threshold on validation; open the test only for the frozen candidate and baseline.
labels = [0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]
train, validation, test = labels[:6], labels[6:9], labels[9:]
base_rate = sum(train) / len(train)
baseline_scores = [base_rate] * len(validation)
candidate_scores = [0.25, 0.55, 0.70]
def brier(actual, scores):
return sum((y - p) ** 2 for y, p in zip(actual, scores)) / len(actual)
print("train base rate", round(base_rate, 3))
print("validation baseline", round(brier(validation, baseline_scores), 3))
print("validation candidate", round(brier(validation, candidate_scores), 3))
print("sealed test rows", len(test))Compare a candidate with a train-only base-rate baseline.
What to notice
- The baseline probability uses training labels only; folding validation labels into it would make the comparison optimistic.
- The code reports the test size but computes no test metric while model choices are still being made.
YOUR TURN Pause and predict before revealing the answer.
Why is a random row split risky when each customer appears in many rows?
Need a hint?
Ask whether the validation set contains an identity already summarized by training.
Check your reasoning
The model can exploit customer-specific history learned in training, so validation measures recognition of known customers rather than generalization to the deployment population.
Lessons 1, 2 in this course.
Connect the chapter to the course’s quantitative spine.
A baseline sets the floor; an honest split keeps the ruler straight. The cost-aware threshold selection below is the shared course-level lens that helps quantify the surrounding system. Name each symbol, check its units or shape, and use only values that were available at the production cutoff.
Cost-aware threshold selection
| Symbol | Meaning / shape / unit |
|---|---|
t | decision threshold |
FN, FP | error counts at t |
c_FN, c_FP | business cost per error |
Open derivation and numerical substitution
Start from the production quantity being optimized, substitute the observed values with their declared units, then isolate the model-controlled term. Preserve shape annotations at each step so broadcasting or aggregation cannot silently change the result.
- Write the named inputs: t, FN, FP, c_FN, c_FP.
- Substitute one small, hand-checkable batch before vectorizing.
- Calculate an independent reference value and compare within a declared tolerance.
# equation → code contract
inputs = validate_shapes_and_units(batch)
value = compute_c02(inputs)
assert is_finite(value)Change one assumption and make the tradeoff visible.
Use the worked chapter as your prediction, then change one input in the lab and explain why the output moves. The lab runs predefined TypeScript and never executes learner code, so the focus stays on the concept rather than setup.
Cost-aware threshold
Move the cutoff over a fixed set of scored transactions.
Assumption: Fixed 12-event dataset; false positive costs 2 units and false negative costs 12.
Open nonvisual data table
| Item | Computed state | Interpretation |
|---|---|---|
| 0.92 | fraud | review |
| 0.84 | fraud | review |
| 0.76 | legit | review |
| 0.68 | fraud | review |
| 0.59 | legit | review |
| 0.51 | fraud | review |
| 0.43 | legit | pass |
| 0.37 | legit | pass |
| 0.31 | fraud | pass |
| 0.22 | legit | pass |
| 0.14 | legit | pass |
| 0.08 | legit | pass |
Trace the complete operating path.
Carry the chapter’s central idea into the system: A baseline sets the floor; an honest split keeps the ruler straight. The path below shows where that reasoning needs an artifact, a test, an owner, or a fallback.
- 01
Turn “Choose a hard-to-cheat baseline” into a written invariant and a failing test.
- 02
Promote honest_split.py from illustration to a versioned implementation with representative fixtures.
- 03
Use “Tune once, test once” as the release checkpoint: Select features, hyperparameters, and threshold on validation; open the test only for the frozen candidate and baseline.
- 04
Serve or materialize behind explicit a declared latency, cost, and operator-capacity budget.
- 05
Join telemetry to mature outcomes and retain a rollback path.
Observability
Join service health, input quality, prediction distributions, slice behavior, and mature outcomes by exact version.
Cost
Measure storage, preprocessing, compute, queueing, and human review under a representative arrival pattern.
Failure modes
ROC-AUC alone on 0.1% prevalence hides unusable precision and an impossible review queue. Add a detector, owner, mitigation, and stop condition for this class of failure.
Alternatives
Compare a rule, a simpler statistical baseline, and a different system boundary before adding model complexity.
Explain the contract, not just the vocabulary.
Late-delivery evaluation contract
Specify a cutoff-safe target, validation design, cost/capacity threshold, calibration report, uncertainty, and controlled experiment.
- Decision and metric contract
- Leakage-safe split tests
- Threshold and calibration analysis
- A/B guardrails and rollback
Read primary material with a purpose.
Return to the opening failure.
Store the decision contract, cutoff, split logic, threshold policy, uncertainty, and experiment design beside the model.
For this lesson, the release evidence is the worked code example, a hand-checked formal result, deterministic simulation output, a ≥80% checkpoint, the production rubric, and a named fallback. The course resolves when the system can produce a metric contract, leakage-safe validation, calibration analysis, and experiment plan.