The question
Every real study ends with the same unanswerable complaint: my score stopped moving — is my model bad, or is this as good as it gets? Nobody can tell you, because on real data nobody knows the best score that was ever available.
This study buys that answer by giving up something else. The evidence here is not
found, it is generated: prepare.py writes out the exact
process that produced every row, so the best score any model could possibly reach is
not a guess but a computation. That one fact turns two vague worries into
arithmetic:
- How far is my model from the best possible? Computable, because the truth is declared.
- Is that distance big enough for my measurement to see? Computable too, once the noise floor has been measured.
So the study climbs a four-rung ladder of ordinary tabular models and asks, at every rung, how much of the distance to the known ceiling it has closed — measured not in metric units but in units of what the measurement can actually resolve. Then it spends its one look at held-out data to check the answer.
The decision a reader takes away is not “use gradient boosting”. It is when to stop, and how to know you have reached that point rather than guessing.
The method
Two ideas do all the work here, and neither of them is a model.
The ceiling
Imagine grading weather forecasters. Even a forecaster who knows the true probability of rain for every single day will not score perfectly, because it sometimes fails to rain on an eighty-percent day. There is a best possible score, and the world's coin flips set it, not the forecaster. That is the Bayes ceiling.
The generating process is a logistic model with one interaction and one quadratic term, so the truth is smooth but not linear in the raw features:
and each row's label is a coin flip weighted by that log-odds:
AUC is the probability that a random positive outranks a random negative, so it depends on a score only through the order it puts the rows in. The true probability is by construction the best ordering there is, so no score can beat it:
That is why the ceiling is computable here and nowhere else. Note the subtlety the study had to respect: it is a ceiling for these rows. A different draw of four thousand rows has its own ceiling, which is why the sealed prediction was written with a tolerance instead of as an equality.
The detection limit
Now put the ceiling next to the noise floor — how much the metric moves when nothing about the model changes. Their ratio is the headroom:
where is the measured floor, the smallest improvement that counts. If , then even a perfect model could not beat your current one by an amount your measurement could tell apart from noise. The tournament is decided before it runs.
Two warnings the field paid for, repeated here. First, means only “not arithmetically excluded” — never “worth trying”; the attainable ceiling usually sits well below the ideal one. Second, the floor you divide by must be the floor that judges your comparison. That second warning is the one this study nearly walked into, and section four shows how close it came.
The data story
Twenty thousand rows, eight standard-normal features, one binary label. Six features
enter the true log-odds; x7 and x8 enter nothing at all, and
they are there so the study can watch a high-capacity model spend budget on columns
that carry no signal. The positive rate is 24.115%, and the contract splits the table
60/20/20 into 12000 training rows, 4000 development rows, and 4000 rows that stay
sealed until the very last run.
The value-pattern check — the one the data gate never skips, because pandas cannot tell a Yes/No column from any other string column by dtype alone — found eight honest floats and a genuine binary integer. No sentinels, no numbers-in-strings, no string-encoded booleans. On synthetic data that is unsurprising; running it anyway is the point, because the day you skip it is the day it would have mattered.
Where the truth lives, and where it must not
prepare.py computes the true log-odds for every row and writes them to
data/prepared/truth.json — and only there. Joining
that column into the feature table would be perfect target leakage: the model would be
handed the answer. The clean-room audit checked exactly this, in a fresh context on a
different model, reading only the contract, the preparation script and the prepared
table — never the lab notebook, whose hopes and priors are what make a leak look
plausible.
The two controls
Before trusting any verdict the pipeline was checked in both directions. Most studies do this and never name it; naming it is half the teaching.
- Negative control — a known-absent effect must
score at chance. A constant predictor and a label-shuffled predictor scored
val_auc=0.5000andval_auc=0.5011against a chance anchor of 0.5. A harness that scores noise above chance cannot be believed about anything else. - Positive control — a known-present effect must be detected. The second rung hands the model the interaction the generating process is known to contain, so a working pipeline is obliged to find it. It did, by 3.9699 floors.
The gate ruled GO with two warnings carried forward rather than argued away: a 24% positive rate, and a development partition of only four thousand rows — which is what makes the noise floor wide, and therefore what makes the headroom close early. Both warnings landed in the arithmetic, not in a claim.
The experiment journey
Phase 0: two floors, and only one of them is a bar
Before any candidate ran, the study measured how much its own metric moves when nothing improves. It measured this twice, two different ways, and the two answers disagreed by everything.
Refitting the same anchor on the same rows under five different fit seeds moved the score not at all: standard deviation 0, range 0. A convex solver on a fixed partition is deterministic. Re-drawing which rows are held out and re-measuring moved it with a standard deviation of 0.00372606 over ten draws, giving a keep bar of
This is the trap the whole discipline exists to avoid. A study that had pasted the
cheap number into its contract would have carried a keep bar of zero and would
have kept every candidate that moved the last decimal. Klein records the two under
different keys — fit_noise for provenance, noise_floor
for the bar — so the cheap one can never be mistaken for the expensive one.
The ladder
Four candidates, each one falsifiable idea, each committed before it ran. Every run printed its own distance to the ceiling and its paired lift over the rung it claimed to beat — the predecessor refitted on the same rows inside the same run, so the comparison lives in one printed block instead of being reconstructed afterwards.
Tracks: primary — val_auc (higher is better)
| Exp | Track | Kind | Metric | Status | Description |
|---|---|---|---|---|---|
| E0001 | primary | development | 0.806201 | keep | E0001 anchor: the raw-feature logistic identity anchor — how far is a single hyperplane from the known ceiling?; first valid result on this track |
| E0002 | primary | development | 0.835785 | keep | E0002: hand the linear model the DGP's true x1*x2 interaction — does the term the hyperplane could not express buy more than a floor?; frontier improvement over 0.806201 with minimum_delta=0.00745212 |
| E0003 | primary | development | 0.87139 | keep | E0003: a boosted tree told none of the true terms — can it beat the hand-specified interaction rung it was never shown?; frontier improvement over 0.835785 with minimum_delta=0.00745212 |
| E0004 | primary | development | 0.858049 | discard | E0004: the over-capacity boosted tree — 500 trees, 127 leaves, no shrinkage discipline, no early stopping. Does buying capacity at h = 1.708 buy anything the floor can see?; did not improve track frontier 0.87139 by minimum_delta=0.00745212 |
| E0005 | primary | final_test | 0.880949 | discard | E0005 sealed: E0003's configuration, once, on the held-out partition — does it land within two measured floors of that partition's own Bayes ceiling?; sealed final-test evidence; excluded from the adaptive frontier |
Before spending the fourth candidate the study read its headroom: . Ajar, not open — so the detection-limit law neither refused the run nor demanded an acknowledgement. The study spent it anyway, on an over-capacity boosted tree with five times the trees, no shrinkage discipline and no early stopping.
It came back worse: delta_in_floors -1.7903 against
its own reference, a discard. And it broke the probabilities long before it broke the
ranking — log-loss went from 0.355165 to 1.024102, nearly triple, while the
AUC change was only delta_vs_reference -0.013341. It also cost
18.407609 seconds against 0.647123.
That refuted a registered prediction. P4 was written as a no-effect prediction — “within noise” — and the honest reading of a refuted no-effect prediction is not “nothing happened after all” but “something happened, in the wrong direction”. The study wrote that down, dated, and stopped buying capacity.
The one sealed look
The sealed partition was rehearsed first — a dry run that executes the whole path on development data and spends nothing, because an earlier study lost its only seal to a crash that happened before any data was read. Then it was spent once. The selected configuration scored 0.880949 against that partition's own ceiling of 0.893469, a distance of 1.68 floors against 1.7077 on development.
The distance to the ceiling did not grow when the rows changed. That is what “the remaining gap is irreducible at this sample size” looks like when you can actually see the ceiling.
Findings and insights
The ladder closed the distance to the development ceiling of 0.884116 from 10.4555 measured floors at the raw-feature anchor to 1.7077 at the boosted incumbent, and the sealed partition returned 0.880949 against its own ceiling of 0.893469. That claim is the only kind this study is allowed to call confirmed: it cites both a development run and the sealed run, which are two different kinds of evidence.
The result a practitioner should take away carries the scope tag
in-silico, because it is a statement about behaviour under this
declared process and not about the world: a boosted tree shown
none of the true terms out-earned handing a linear model the true interaction
— 4.7779 floors against 3.9699, and 4.6190 on the sealed rows. Nobody had to know
which term to specify.
Where the linear model actually goes wrong
The ranking gap and the probability gap are the same missing structure seen twice: Brier 0.132010 for the linear model against the boosted tree's 0.109337 and the irreducible Bayes floor of 0.103604.
The prediction the study got wrong, and the one it was wrong about
Five predictions were registered before any evidence existed. Four were supported and one refuted, every one adjudicated by arithmetic on a printed block rather than by prose. The family size is five, each bound to exactly one run, with no post-hoc selection — so the guard here is pre-registration rather than an alpha correction.
The second research question was refuted, and that is the most useful sentence on this page. It predicted the headroom would close before the fourth candidate was spent; it stood at 1.708 instead. The law did not stop the study, the study paid for the discard in full, and the prior that said otherwise was recorded as a miss rather than quietly rewritten.
Two replications that failed, and were kept
Both attempts to replicate the incumbent run failed, and neither failure was scientific. The first timed out: a replication builds its own environment in a detached worktree before the entrypoint runs at all, and this study's honest per-run budget was sized for runs that take under a second. The second crashed on a prepared artifact that the entrypoint reads but the contract never declared — so the replication harness, which copies exactly what the contract names, never copied it.
Both records stand at not reproduced. Neither was retried into a pass, and the entrypoint was not quietly edited afterwards to make an unproven fix look proven. The failure became a claim instead, which is the single most useful thing here for the next author.
What the records say
Everything below is copied out of this study's own records at build time —
claims.lock and study_state.json — rather than retyped
into the prose above, so the page cannot drift from the ledger it describes.
- claims
8locked inclaims.lock- by strength
- confirmed
2· exploratory6 - by class
- empirical-description
2· known-dgp-teaching1· mechanism-interpretation1· procedural-verdict1· research-discipline3 - errata
0of8claims tagged ·0erratum record(s) in the lock- locked at
2b29e93bf0b3· klein2.0.0- label
- confirmed
- referee
- PASS-WITH-NOTES —
klein-referee (Claude Code subagent, model: claude-opus-5[1m])· independent of the experimenter: no
Method coding advice
Here is the entire per-experiment surface of this study — the actual bytes,
included by reference so this page cannot drift from the code that produced the numbers
above. Read the two constants in the middle first: CANDIDATE and
REFERENCE. That two-line diff is an experiment.
train.py · executed by E0003 (development, track primary) at commit 061a079ab2b9 · sha256 147b24920cf6…
"""The only per-candidate mutable surface in this study.
The per-experiment diff is two constants — ``CANDIDATE`` (the rung being tried)
and ``REFERENCE`` (the rung it claims to beat) — and nothing else. Everything
below them is fixed machinery.
What every run prints, on top of the canonical block
---------------------------------------------------
Because the truth is declared, each run can report where it stands relative to
things a normal study can only guess at. All of them are read from the contract
and from ``data/prepared/truth.json``; none is written here as a literal:
===================== ==========================================================
``bayes_auc`` the Bayes-optimal AUC for exactly the rows this run was
graded on, from the DGP's true log-odds
``gap_to_ideal`` ``bayes_auc - val_auc``: how far this rung is from the
ceiling, in metric units
``gap_in_floors`` the same distance divided by the contract's
``minimum_delta`` — i.e. **this run's own headroom h**,
the number the detection-limit law is about
``reference_auc`` the named reference rung refitted on the SAME rows (common
random numbers), so the comparison lives in one block
``delta_vs_reference`` ``val_auc - reference_auc``
``delta_in_floors`` that lift in units of the measured floor
===================== ==========================================================
`gap_in_floors` and `delta_in_floors` are printed only once the contract carries
a measured ``minimum_delta``; before Phase 0 sets it there is no floor to divide
by, and a prediction whose key is not printed is INCONCLUSIVE rather than
refuted, which is the honest answer.
The partition comes from ``kleinlib.data.load_partition`` (which prints the
``split_fingerprint:`` the notary checks against the DATA gate) and the ceiling
is looked up by row label, so the sealed dry-run — which hands back development
rows — reports the development ceiling without this file knowing anything about
it.
"""
from __future__ import annotations
import json
import os
import time
from pathlib import Path
import numpy as np
import pandas as pd
from sklearn.ensemble import HistGradientBoostingClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
import kleinlib
from kleinlib.contract import load_contract
from kleinlib.data import load_partition
RANDOM_SEED = 42
SMOKE = os.environ.get("KLEIN_SMOKE") == "1"
EXPERIMENT_ID = os.environ.get("KLEIN_EXPERIMENT_ID") or ("SMOKE" if SMOKE else None)
TRACK = os.environ.get("KLEIN_TRACK") or ("primary" if SMOKE else None)
TRUTH_PATH = Path("data/prepared/truth.json")
def _with_interaction(X: pd.DataFrame) -> pd.DataFrame:
"""Hand the linear model the DGP's true two-way interaction term."""
out = X.copy()
out["x1_x2"] = out["x1"] * out["x2"]
return out
#: The ladder's rungs. A recipe is (feature builder or None, estimator factory).
#: Adding a rung is a deliberate edit to this library; choosing one is the
#: per-experiment idea.
RECIPES = {
"logreg_raw": (
None,
lambda: make_pipeline(
StandardScaler(),
LogisticRegression(max_iter=1000, random_state=RANDOM_SEED),
),
),
"logreg_interaction": (
_with_interaction,
lambda: make_pipeline(
StandardScaler(),
LogisticRegression(max_iter=1000, random_state=RANDOM_SEED),
),
),
"hgbt_default": (
None,
lambda: HistGradientBoostingClassifier(random_state=RANDOM_SEED),
),
"hgbt_overcapacity": (
None,
lambda: HistGradientBoostingClassifier(
max_iter=500,
learning_rate=0.25,
max_leaf_nodes=127,
min_samples_leaf=1,
l2_regularization=0.0,
early_stopping=False,
random_state=RANDOM_SEED,
),
),
}
# --- the candidate: the whole per-experiment diff surface -------------------
CANDIDATE = "hgbt_default" # E0003: a boosted tree, told none of the true terms
REFERENCE = "logreg_interaction" # the hand-specified rung it claims to beat
def fit_recipe(name: str, X_fit: pd.DataFrame, y_fit: pd.Series):
"""Fit one rung; return the model and the feature transform it expects."""
build, make = RECIPES[name]
transform = build or (lambda frame: frame)
model = make()
model.fit(transform(X_fit), y_fit)
return model, transform
def positive_probabilities(model, X: pd.DataFrame) -> np.ndarray:
return np.asarray(model.predict_proba(X))[:, 1]
def ceiling_for(rows: pd.Index, y_eval: pd.Series) -> float:
"""The Bayes AUC of exactly these rows, from the declared true log-odds."""
eta = np.asarray(json.loads(TRUTH_PATH.read_text(encoding="utf-8"))["true_log_odds"], dtype=float)
probability = 1.0 / (1.0 + np.exp(-eta[np.asarray(rows)]))
return float(roc_auc_score(y_eval, probability))
def main() -> None:
t0 = time.time()
evaluation_kind = os.environ.get("KLEIN_EVALUATION_KIND")
if SMOKE:
evaluation_kind = evaluation_kind or "development"
missing = [
name
for name, value in (
("KLEIN_EVALUATION_KIND", evaluation_kind),
("KLEIN_EXPERIMENT_ID", EXPERIMENT_ID),
("KLEIN_TRACK", TRACK),
)
if value is None
]
if missing:
raise RuntimeError(
"train.py must be invoked through `klein run-one`. For a pre-run "
"syntax/shape check use `KLEIN_SMOKE=1 python train.py` — it prints "
"the canonical block, writes no sidecars or snapshots, and is not "
"evidence. Missing: " + ", ".join(missing)
)
X_fit, X_eval, y_fit, y_eval = load_partition(evaluation_kind, study_dir=".")
minimum_delta = float(
load_contract(".")["tracks"][TRACK]["metric"].get("minimum_delta") or 0.0
)
fit_start = time.time()
model, transform = fit_recipe(CANDIDATE, X_fit, y_fit)
fit_seconds = time.time() - fit_start
X_eval_t = transform(X_eval)
# The same arithmetic `evaluate` is about to do, computed here so the
# distance to the ceiling can be printed alongside the score rather than
# reconstructed by a reader afterwards.
candidate_auc = float(roc_auc_score(y_eval, positive_probabilities(model, X_eval_t)))
bayes_auc = ceiling_for(X_eval.index, y_eval)
extra: dict[str, str] = {
"bayes_auc": f"{bayes_auc:.6f}",
"gap_to_ideal": f"{bayes_auc - candidate_auc:.6f}",
}
if minimum_delta > 0:
extra["gap_in_floors"] = f"{(bayes_auc - candidate_auc) / minimum_delta:.4f}"
if REFERENCE is not None:
reference_model, reference_transform = fit_recipe(REFERENCE, X_fit, y_fit)
reference_auc = float(
roc_auc_score(
y_eval, positive_probabilities(reference_model, reference_transform(X_eval))
)
)
extra["reference_auc"] = f"{reference_auc:.6f}"
extra["delta_vs_reference"] = f"{candidate_auc - reference_auc:.6f}"
if minimum_delta > 0:
extra["delta_in_floors"] = f"{(candidate_auc - reference_auc) / minimum_delta:.4f}"
kleinlib.eval.evaluate(
model,
X_eval_t,
y_eval,
exp_id=EXPERIMENT_ID,
study_dir=".",
t0=t0,
fit_seconds=fit_seconds,
train_n=len(X_fit),
val_n=len(X_eval),
metric_name="val_auc",
metric_goal="higher",
extra=extra,
)
if __name__ == "__main__":
main()
Four things worth stealing
- Read the bar from the contract; never write it as a literal.
minimum_deltais loaded fromstudy.yamlat the top ofmain. A hardcoded bar and a hardcoded split seed are the same bug, and the second one already cost an earlier study a whole ledger lane measured on the wrong partition. - Route every partition through
load_partition. It prints thesplit_fingerprint:line the notary compares against the fingerprint the data gate froze, so a partition that silently changed is a crash by design rather than a mystery. It is also what lets the sealed dry run hand back development rows without the entrypoint knowing anything about it. - Print the comparison; do not reconstruct it. Every run refits its
named reference rung on the same rows and prints
delta_vs_referenceanddelta_in_floors. That costs one cheap fit and buys a registered prediction that arithmetic can decide from a single printed block. - Guard the divide. The floor-relative keys are printed only when
minimum_deltais above zero. Before Phase 0 there is no floor to divide by, and a prediction whose key was never printed comes back inconclusive rather than refuted — the honest answer, and also what made the pre-gate smoke check harmless.
Two things this study got wrong, kept, and wrote down
- An undeclared artifact breaks replication.
train.pyreadsdata/prepared/truth.json, which the contract never declared, so the replication harness never copied it and the re-run crashed. Declare every artifact your entrypoint reads, or derive it from committed code. This was found by attempting a replication the confirmation contract did not even require — which is the argument for attempting one anyway. - An audit that reaches past its own reading scope writes confident, false
sentences. The data card asserts there is no literal seed in any script
the study owns;
RANDOM_SEED = 42is right there in the file above. It is a fit seed, it is harmless, and the split is contract-driven — but the sentence was asserted about a file the clean-room auditor states it never read. The card is gate-hashed, so it was not edited after the fact; the correction lives in the lab notebook and the findings, where an append-only record belongs.
Next steps
- Give the replication path something it can copy. Either declare the truth as part of the prepared artifact, or recompute the ceiling from the generator's committed coefficients instead of reading a cache. Then re-run the replication and watch the record come back reproduced. Cheapest fix, highest value.
- Measure a paired floor. Every delta here is paired — each run refits its reference on the same rows — but it is divided by a marginal floor, because that is the bar a frontier keep must clear. A paired-bootstrap floor would be the sharper denominator, and the two side by side would show what the conservative choice costs in resolution.
- Vary the sample size and watch the headroom close. Both terms of the ratio move with the number of rows: more rows shrink the floor and let the boosted tree get closer. The same four rungs at several table sizes would turn a single reading of the detection limit into a curve.
- Try a middle rung. The permission to say anything about capacity here comes from one extreme point. A shrunk, early-stopped boosted tree between the two measured settings would say whether the loss is a cliff or a slope.
References
All four were checked against the publisher or arXiv page before any run, and none
of them carries a confirmed claim on its own. The complete citation for each —
volume, pages, the date it was verified and by what — is in the study's
references.yaml and on the method card; what follows is what a reader
needs to find the work and to see why it is here.
- Hanley & McNeil, The meaning and use of the area under a receiver operating characteristic (ROC) curve, Radiology, doi:10.1148/radiology.143.1.7063747 — the identity that makes the ceiling computable at all: AUC depends on a score only through the order it induces.
- Friedman, Greedy function approximation: a gradient boosting machine, The Annals of Statistics, doi:10.1214/aos/1013203451 — the stagewise additive fit that recovered the interaction and the quadratic without being shown either.
- Ke et al., LightGBM: a highly efficient gradient boosting decision tree, Advances in Neural Information Processing Systems — the histogram-binned gradient-boosted tree this study actually runs.
- Grinsztajn, Oyallon & Varoquaux, Why do tree-based models still outperform deep learning on tabular data?, NeurIPS Datasets and Benchmarks Track, arXiv:2207.08815 — the doctrine anchor for a medium-sized table, and the reason the ladder's top rung is a boosted tree.