Benchmark¶
symphony-dt bench runs five synthetic scenarios with known truth and scores every method with the frozen
code-of-record specification.
| scenario | what changes |
|---|---|
| dense | visits every six months to a year |
| sparse | few visits, one to two years apart |
| floor | motor scores pushed toward zero |
| dropout | a participant leaves after the motor score passes 40 |
| drift | from year three, motor scores read three points high |
By default the twin is the living twin on the generating parameters, an oracle population. This isolates the participant-level machinery and the scoring from population estimation. Baselines are LOCF and the linear mixed model of the scoring code.
Run symphony-dt bench --out benchmark.csv to reproduce the table on your machine. These are synthetic results.
They say nothing about performance on any clinical cohort.
Estimated population (EXPERIMENTAL)¶
run_benchmark(population="estimated") adds population estimation to the comparison. For each scenario it fits
pd_v2 on the fit data of the split and runs the twin on draws read with PopulationDraws.from_fit. The fit data
hold every training participant's full record and each test participant's visits up to the anchor. The LMM
baseline sees the same data.
from symphony_dt.bench import run_benchmark
table = run_benchmark(
["sparse"],
population="estimated",
fit_options={"chains": 4, "iter_warmup": 1000, "iter_sampling": 1000, "seed": 1, "n_draws": 200},
)
fit_options passes keyword arguments to symphony_dt.fit.fit. Its n_draws sets how many evenly spaced draws
the twin keeps. With output_dir, each scenario's chains are kept in a folder named after the scenario. Without
it, the chains go to a temporary folder that is removed after the draws are read.
The column population_kind records oracle, estimated or supplied, the last for a PopulationDraws you
pass. The column population names the source of the draws. The default stays the oracle. Stan fits are slow,
so the estimated route is tested only in the slow suite. The gap between the oracle and estimated rows shows
what estimation costs on synthetic data. It is not a convergence check: read the fit's gates for that.
External methods on equal terms (TESTED)¶
Any forecasting method can be scored against the twin and both baselines on the same targets.
benchmark_scenario builds one scenario. benchmark_targets returns the history a method may see and the
targets it must forecast. score_predictions scores the method's forecast draws.
from symphony_dt.bench import benchmark_scenario, benchmark_targets, score_predictions
scenario = benchmark_scenario("sparse", n=120, n_test=40, seed=0)
history, targets = benchmark_targets(scenario)
predictions = my_method(history, targets) # columns: participant_id, endpoint, time_days, draw, value
table = score_predictions(scenario, predictions, label="my_method")
The history is a TwinDataset with the same data the LMM baseline sees. The targets table has one row per
held-out observation, with participant_id, endpoint, time_days and horizon_years. It holds no outcome
values. Times are whole days since baseline, as in the history.
The predictions table is long, with one row per target and draw:
| column | meaning |
|---|---|
| participant_id | as in the targets table |
| endpoint | updrs3, moca or scopa_aut |
| time_days | as in the targets table |
| draw | any label, unique within a target |
| value | one forecast draw on the instrument's scale |
Validation is strict, and each breach raises ValueError. The checks catch a missing target, a target that is
not held out and a repeated draw label. They also catch unequal draw counts, a missing or non-finite value and a
value outside the scale bounds. Row order and draw labels do not change the scores.
The result has the layout of run_benchmark without its population columns. The method's rows are named
label and label_all. The paired rows crps_diff_<label>_minus_locf and crps_diff_<label>_minus_lmm
compare it with each baseline. Seeds follow the scenario's place in SCENARIOS, so benchmark_scenario matches
the same scenario inside run_benchmark.
Two tests pin the scoring. The twin's own draws, written as a predictions table by twin_predictions, score
exactly as the twin inside run_benchmark. A method that predicts each held-out value exactly scores coverage of
1 and a CRPS of 0. Scores describe forecasts against simulated observations only. They support no causal,
treatment or deployment claim.