Skip to content

betting_combat.strategies.bart

bart — BART survival for a discrete-time hazard (Sam 2026-11-16): one row per unit x period at risk, the chance the event happens in the period = sigmoid(offset + BART(inputs)). The offset is the starting point the trees correct (for the rounds strategy: our price level recalibrated), so the trees learn only the correction. Bayesian Additive Regression Trees (pymc-bart), fitted by MCMC.

BartSurvival fit(X, y, offset) / predict(X, offset) -> the chance per row (the mean over the posterior's trees);
to_bytes / from_bytes: the fitted trees saved and rebuilt (pymc-bart's own history of the forest; the
rebuilt model predicts exactly what the fitted one does)

pymc and pymc-bart are imported only when a model is fitted or rebuilt, so the rest of the package runs without them. Research: data/ufc/cito/assess/final_v1 (m14: BART survival on the purged folds; m15: the save / rebuild check).

Classes

BartSurvival

trees sum-of-trees size; draws / tune / chains the MCMC; predict_draws how many posterior forests a prediction averages; seed. After fit: the forest’s history (_history) and its rebuilt sampler.

correction

correction(X: np.ndarray, seed: int | None = None) -> np.ndarray

The trees’ correction (log-odds) per row and posterior draw: draws x rows.

fit

fit(X: np.ndarray, y: np.ndarray, offset: np.ndarray) -> BartSurvival

from_bytes

from_bytes(b: bytes) -> BartSurvival

predict

predict(X: np.ndarray, offset: np.ndarray, seed: int | None = None) -> np.ndarray

The chance of the event per row: the mean over posterior draws of sigmoid(offset + correction).

to_bytes

to_bytes() -> bytes