betting_combat.models.folds
folds — the simulators’ out-of-sample machinery (Sam 2026-11-19), one place for all three:
1 the setup and the training set (each simulator's own cards: the cards whose real data it learns from)2 steps 3-4: every training card predicted by a fit on ALL THE OTHER cards (one card held out at a time) - its rows' ``src`` 'oos', ``fold`` the card held out3 step 5: the final fit on every training card forecasts every row with no real data - ``src`` 'forecast', ``fold`` 'final'4 step 6, each new card: the saved final model predicts it (it never saw it) - ``src`` 'oos', ``fold`` 'saved:<version>' - then the final model is refitted with the card in and saved
run_folds a task over items (one card each), in worker processes sharing one copy of the inputscheck_out_of_sample THE GUARD: stops the build when a simulated row came from a fit that saw its cardFunctions
check_out_of_sample
check_out_of_sample(rows: pd.DataFrame, name: str, train_cards: set[str], card: str = 'event_id', src: str = 'src', fold: str = 'fold', saved_cards: dict[str, set[str]] | None = None) -> intTHE GUARD: every simulated row came from a fit that never saw its card - ‘oos’ rows from the fit that held their own card
out (fold = the card) or from a saved model that never had it (fold ‘saved:saved_cards), ‘forecast’ rows from the final fit on cards that are not theirs (train_cards: the final
fit’s). Raises with the offending rows; returns the rows checked.
run_folds
run_folds(task: Callable[[Any, Any], Any], items: Iterable[Any], payload: Any, n_jobs: int = 1) -> list[Any]task(payload, item) for every item, in order. n_jobs > 1: that many worker processes (spawned), each loading
payload once from a temporary file; task must be a module-level function.