symphony_dt.fit¶
symphony_dt.fit ¶
Fit a registered model with CmdStan NUTS, with chain-level checkpoint and resume.
Chains are written to chains/ and named by chain id. A chain whose CSV holds every requested draw is
complete. With resume=True, complete chains are kept and only missing or incomplete chains run,
with the same seed and chain id, so a resumed fit equals an uninterrupted one. Every fit writes
fit_manifest.json beside the chains.
FitResult
dataclass
¶
The result of fit: chain CSV files, settings and the run manifest.
Validation: TESTED.
draws ¶
draws(name: str) -> np.ndarray
Return draws of one column, shaped (draws, chains).
Validation: TESTED.
gates ¶
gates(
*, override: GateOverride | None = None
) -> GateReport
Evaluate the convergence gates on every chain.
Validation: VALIDATED.
to_inference_data ¶
to_inference_data(*, globals_only: bool = True) -> Any
Return an ArviZ InferenceData. With globals_only, per-participant blocks are dropped.
Validation: TESTED.
save_manifest ¶
save_manifest() -> Path
Write the manifest to fit_manifest.json in the output folder.
Validation: TESTED.
chain_is_complete ¶
chain_is_complete(
csv_file: str | Path, iter_sampling: int
) -> bool
Return True when a CmdStan chain CSV holds iter_sampling draws and its timing footer.
Validation: TESTED.
fit ¶
fit(
stan_data: StanData,
*,
model: str = "pd_v2",
chains: int = 4,
iter_warmup: int = 1000,
iter_sampling: int = 1000,
seed: int = C.MASTER_SEED,
chain_ids: Sequence[int] | None = None,
threads_per_chain: int = 1,
parallel_chains: int | None = None,
inits: Literal["prior", "random"]
| dict[str, Any] = "prior",
output_dir: str | Path | None = None,
resume: bool = False,
adapt_delta: float = 0.8,
max_treedepth: int = 10,
show_progress: bool = False,
) -> FitResult
Sample the posterior of model given stan_data and return the chains.
inits="prior" starts every chain at the prior location with per-chain jitter (the study's
SBC rule); "random" uses CmdStan's default uniform(-2, 2) box, as the study's held-out fits
did. With resume=True, complete chains in output_dir are kept and only the rest run.
Validation: TESTED. The sampler settings the study used are the defaults of its own drivers; this function runs them, it does not validate them.
load_fit ¶
load_fit(output_dir: str | Path) -> FitResult
Load a fit written by fit from its output folder.
Validation: TESTED.