Out-of-sample evaluation: frozen models¶
This page explains how to reproduce reports/out_of_sample.md: the forecasters behind the real-time strategies are
trained once on data up to a cutoff T, frozen, and then trade every minute after T next to the same models
retrained every month, the reactive threshold rules and the perfect-foresight oracle. The evidence (P&L per month,
model-ageing curve, paired block-bootstrap statistics, look-ahead audits) is regenerated by one script from the
committed public data set.
Run it¶
python scripts/research/out_of_sample.py # train, simulate, audit, report (about 7 min)
python scripts/research/out_of_sample.py --stages report # rebuild the report from cached results
python scripts/research/out_of_sample.py --quick --out /tmp/oos # smoke test on short windows (under a minute)
Requirements: the project environment with the ml extra (scikit-learn) and the public data set under
data/public (or $EUROFLEX_DATA_DIR).
| Option | Meaning |
|---|---|
--stages |
comma-separated subset of train,simulate,audit,report |
--workers, --threads |
worker processes and OpenMP threads per worker (default 3 and 3) |
--cache |
cache directory (default $EUROFLEX_CACHE_DIR/out_of_sample or ~/.cache/euroflex_bess_lab/out_of_sample) |
--wf-models |
directory with the walk-forward models of realtime_backtest.py (default: its cache) |
--force |
recompute cached stages |
--ablation |
also run the variant whose MPC price profile is frozen at T too (results stay in the local cache) |
--out |
report root (default reports) |
Stages cache their results outside the repository, so an interrupted run resumes where it stopped:
trainfits one frozen forecaster per cutoff and model (price model, SCALES-L state model, zero-history SCALES-L) on a market that ends at T, records the training audit, and reuses the walk-forward models ofscripts/research/realtime_backtest.pywhen they cover the evaluation windows (otherwise it fits the missing monthly folds with the same specification);simulateruns every arm of every evaluation window withrealtime.simulateand computes the monthly forecast skill of the frozen and the retrained forecasters;auditrunscheck_no_lookaheadand a white-box plan comparison for every tradable arm on real-data slices in the first week after each cutoff and late in the window (the oracle is the positive control and must fail);reportcomputes the statistics and writes the report, the figures and the ledgers.
Design¶
| Item | Setting |
|---|---|
| Cutoffs T | end of 2025-06-30, 2025-12-31 and 2026-03-31 (local time, Europe/Brussels) |
| Test windows | (T, end of 2026-10-24] under the current formula; new formula: (end of 2025-12-31, end of 2026-07-31] |
| Training | the six local calendar months before T, every third minute, embargo on target publication |
| Frozen arms | forecast MPC and SCALES-L with the risk filter (current formula); zero-history SCALES-L, with and without the live running new-formula price (new formula) |
| References | the same arms retrained every month, threshold rules on the running price and on the running SI, perfect-foresight oracle |
| Battery | 1 MW / 2 MWh, efficiencies 0.95 / 0.95, SOC 5-95 %, degradation 8 EUR/MWh discharged |
| Information | minute data usable 1 minute after the minute ends, final quarter-hour prices 5 minutes after the quarter-hour |
| Statistics | paired daily P&L, circular block bootstrap with 7-day blocks, 10,000 replicates, 95 % percentile intervals |
The primary arm (SCALES-L with the risk filter) and the design above are fixed in the script before any result is
computed; tests/test_oos_summary.py pins them.
"Frozen" means that no learned parameter changes after T. Inputs that a live system recomputes from data published before each decision keep updating as in operation: running quarter-hour values, recent final prices, Elia's SI forecasts, day-ahead prices, the MPC's 28-day same-time-of-day price profile and 7-day terminal price, and the threshold rules' 14-day bands.
Outputs¶
reports/out_of_sample.mdandreports/figures/oos_ageing.png,oos_cumulative.png,oos_uplift_ci.png;reports/ledgers/oos_<arm>_<formula>_<cutoff>.parquet(+.jsonsidecar): quarter-hour ledgers of the frozen arms in the ledger format ofreports/ledgers/realtime_*(columns ofSimulationResult.qhplusstrategy,mechanism,fleet_mw);reports/ledgers/oos_daily_pnl.parquet: net P&L per local day for every arm of every evaluation (the input of the statistics);reports/ledgers/oos_summary.json: every number of the report, the frozen-fit audits, the walk-forward fold windows and every look-ahead audit row (schema checked byholdout.validate_summary).
Library¶
The reusable pieces live in euroflex_bess_lab.realtime.forecasting.holdout:
from euroflex_bess_lab.realtime.forecasting import PriceForecaster
from euroflex_bess_lab.realtime.forecasting.holdout import evaluate_holdout, fit_frozen, holdout_split
split = holdout_split("2025-12-31", "2026-10-24", train_months=6) # T = end of the local day
forecaster = PriceForecaster()
audit = fit_frozen(forecaster, market, split) # market truncated at T before fitting; raises if not frozen
block = evaluate_holdout(
ledgers,
split,
battery=battery,
mechanism="current",
frozen_arms=["frozen"],
walk_forward={"frozen": "retrained"},
thresholds=["threshold_price", "threshold_si"],
)
holdout_split,HoldoutSplit.fold: the cutoff and the single train/test fold;fit_frozen,frozen_training_audit,assert_frozen: fit once and prove it (one fold, last training decision before T, last target published by T, no data at or after T loaded);perturb_unpublished: replace every value not yet published at a minute by noise;FrozenHistoryForecaster,history_profile: freeze the MPC's price profile at T as well (ablation);paired_comparison,circular_block_bootstrap_indices: paired daily statistics;evaluate_holdout,monthly_rows,ageing_rows,validate_summary: the report's tables and its schema.
Tests¶
tests/test_oos_holdout.py (split, frozen fit, invariance to post-cutoff data, audits on synthetic and real fixture
days), tests/test_oos_stats.py (bootstrap and paired statistics), tests/test_oos_summary.py (summary schema, the
fixed design, consistency of the committed summary and ledgers). The full-data test is marked slow:
EUROFLEX_RUN_SLOW=1 python -m pytest tests/test_oos_holdout.py