betting_combat.models.stats_simulator
stats_simulator — what Cito’s live feed would have shown in every 30-second block of every round since 2015
(Sam 2026-11-17/18, step 3 of the in-round plan): StatsSimulator, one class, one saved model, one refit,
beside PriceSimulator (the round starts’ prices). Each round’s official totals (ufc.rounds) split into
the blocks of features.fight_blocks - adding up to the round’s live totals, cut at its official finish
second, shaped by how it ended.
Two layers, as the live feed came about: the fight second by second: control spells first (one or more per fighter, filling its control seconds, more often late; A’s and B’s never at once); every strike at its own second - distance strikes in open time, ground strikes in the striker’s control, clinch in both - by the round’s time profile, a burst both fighters share (an exchange that runs on) and, on the ground, the striker’s own; which landed (the totals’ count of them, any attempt alike); their targets (legs at distance and early); takedowns (most at the start of the fighter’s spell), knockdowns (with the standing strikes; in a KO the winner’s last seconds before the finish), submission attempts (on the ground; in a submission the winner’s last at the finish), reversals (in the opponent’s control); a KO’s last FLURRY_S the winner’s flurry; a submission’s round ending in a spell the feed how Cito showed it: the live totals’ own error (the official + a real full round’s live minus official, of similar size), the finish it leaves out (a KO’s winner’s last knockdown, a submission’s last attempt: posted after the fight), a clinch strike in the striker’s control called ground, a real round’s readings (their clocks: its waits, its outages), each carrying what happened since the one before into the block its clock falls in (as fight_blocks), control as it accrued, now and then over and taken back every round adds up to its live totals exactly, every block keeps the counts’ hierarchy (sig = distance + clinch + ground = head + body + leg, landed <= attempted, sig <= total)
StatsInputs the reads: official rounds, fights, the live blocks and the readings' clocks (for the fit)StatsSimulator fit (every number from the rounds Cito read: the feed's error and clocks, the families' weights and time profiles, the targets' mix, then the shape numbers on ``STAGES``' grids against the real rounds' ``structure``) / simulate / assess (the gate, below) / save, load (a file beside this module, or ``features.stats_models``)EvenSplit the baseline the gate scores against: each live total split by its average block shareassess, the gate (settled 11-18, data/ufc/cito/assess/inround_grain/g10): 5 runs of the Cito cards, each card
whole in one, fitted on the other 4 and given only the held-out rounds’ official totals and endings; the so-far
counts at every block inside the round against the live feed’s: passes when the middle 80 % holds 75-85 % pooled
over the 9 counts every round has and 70-90 % on sig landed / attempted / control. Held out 11-18: CRPS 0.85 of
the even split’s, middle 80 % 79 %. The timing inside a round beyond what the totals and the ending say (which
block a knockdown fell in) no simulator of the totals has (g10b: the real stats with their timing shuffled keep
28 % of the price walk’s gain from the real stats, this one 33 %).
GUARD: a draw of how the round could have looked live, given its official totals and how it ended - for training and testing in-round rules on history; a model trained on it is judged on real live rounds.
Classes
EvenSplit
The baseline: each live total split over the round’s blocks by its average share (the partial last block by its seconds); no feed layer (every block seen).
fit
fit(R: pd.DataFrame, blocks: pd.DataFrame, clocks: pd.DataFrame | None = None) -> EvenSplitsimulate
simulate(R: pd.DataFrame, draws: int = 1, seed: int = 0) -> pd.DataFrameLiveError
The live feed’s own error on a fighter-round’s totals: a real fighter-round’s live minus official (a
full round Cito read from the lines, its last block seen), drawn from those of similar size (bins
quantile bins of the official significant attempts); and the finish the feed often leaves out (posted
after the fight): a KO’s winner’s last knockdown (p_kd_drop), a submission’s winner’s last attempt
(p_sub_drop) - the share of such finishes (their last block seen) whose live count fell short; and what
the feed posts in the break after a round (its corrections to it: brk, the break’s two blocks), drawn
with the round’s error from the same real fighter-round: one with a break after it whose last reading came
at the horn (HORN_READ_S) - so its break holds only corrections (the simulator adds what came after its
own round’s last reading: Cito 11-18, rounds whose last reading came before 299 s post +0.6 sig strikes a
fighter-round in the break, those read to the horn +0.1).
draw
draw(off: np.ndarray, rng: np.random.Generator, end: np.ndarray, win: np.ndarray, last: np.ndarray | None = None) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]Live totals for official ones (U, 2, 22) of rounds ending end (END codes) won by win: + a
drawn error, repaired, a finish’s last blow taken out at the feed’s rate; kept (U,): a KO’s /
submission’s finishing knockdown / attempt is in the live totals; brk (U, 2 fighters, 2 blocks, 22)
and brk_rd (U, 2): what the feed posts in the break after the round (none after the fight’s
last round), from the same real fighter-round as the error.
fit
fit(R: pd.DataFrame, blocks: pd.DataFrame, breaks: pd.DataFrame | None = None, clocks: pd.DataFrame | None = None) -> LiveErrorSimulatorRounds
Bases: FeatureTable
features.simulator_rounds: every round Cito read (the stats simulator’s own data - StatsInputs.rounds: its
official totals, length, ending, whether every block was read from the lines, a dead feed) with how a saved simulator
scored on it walk-forward (version: the simulator; its rounds dated after the simulator was saved - score) - one
row per round and simulator scored; version ” : the round’s own row, not yet scored.
StatsInputs
The rounds to split (round_rows) and, for the fit, the live blocks (features.fight_blocks), the
readings’ clocks and what the feed posted in the breaks (break_readings; features.fight_ticks); both windows on
fight_blocks’ walls (a round’s end moved by its clock’s stops).
read
read(db: DBClient, live: bool = True) -> StatsInputsStatsModels
Bases: FeatureTable
features.stats_models: every fitted StatsSimulator, by version.
StatsParams
The simulator’s numbers (module doc). state_w: per family, the weight of a second in (open, own control, the opponent’s); prof: per family, by block; tgt: [missed 0 / landed 1][position][block][target].
StatsSimulator
The in-round stats simulator (module doc). feed=False: the fight layer alone (each count in the block it
happened in; research only - the live feed is part of what it simulates).
assess
assess(inputs: StatsInputs, k: int = GATE_RUNS, n: int = GATE_DRAWS) -> pd.DataFrameThe gate (module doc): k runs of the Cito cards in time, each card whole in one; each run a fresh
simulator (this one’s settings) and the even split fitted on the others, n draws of each held-out
round from its official totals and ending; per count, inside the round: crps / crps_even (lower is
better) and the middle 80 % / 50 % coverage. Sets gate (the rows) and ok; this simulator’s own
fit is left as it was.
fit
fit(inputs: StatsInputs, rounds: pd.DataFrame | None = None) -> StatsSimulatorEvery number from the rounds Cito read (rounds: those of them to learn from, default all; never a
dead feed’s): the live layer, the readings’ clocks (full rounds’), the families’ weights and profiles,
the targets’ mix, then each stage’s grid (STAGES), the strike and takedown profiles calibrated after
the control and the burst stages.
forecast
forecast(rounds: pd.DataFrame, draws: int = 1) -> pd.DataFrameStep 5: rounds on cards this fit never learned from, drawn by it (fold ‘final’).
from_json
from_json(b: dict[str, Any]) -> StatsSimulatorload
load(name: str) -> StatsSimulatorload_db
load_db(db: DBClient, version: str | None = None) -> tuple[StatsSimulator, pd.Timestamp] | NoneThe saved model (the latest, or version) and when it was saved; None when none is.
out_of_sample
out_of_sample(inputs: StatsInputs, rounds: pd.DataFrame, draws: int = 1, n_jobs: int = 1) -> pd.DataFrameSteps 3-4: each training card’s rounds in rounds drawn (draws, seeded by the card) by a fit with this one’s
settings on every OTHER card - the card’s fights taken out of every input (rounds, live blocks, readings’ clocks,
breaks); fold the card. Rounds on cards Cito never read are not here: the final fit forecasts them.
save
save(name: str | None = None) -> PathTo a file beside this module (research; the job keeps its models in the database: save_db).
save_db
save_db(db: DBClient) -> dict[str, int]Into features.stats_models (one row per version: when, and the whole fit as JSON).
score
score(inputs: StatsInputs, rounds: pd.DataFrame, n: int = GATE_DRAWS, seed: int = 7, baseline: pd.DataFrame | None = None) -> pd.DataFrameTHIS simulator (as fitted) on rounds - rounds Cito read, real blocks: n draws of each from its official
totals and ending, the so-far counts at every block inside the round against the live feed’s (as the gate): per
round crps (the gate’s counts pooled), in80 / in50, and crps_even (the even split fitted on baseline - the rounds
before them - the gate’s yardstick). The walk-forward check of a saved simulator on cards it never saw.
settings
settings() -> dict[str, Any]simulate
simulate(rounds: pd.DataFrame, n: int = 1, seed: int | None = None, P: StatsParams | None = None) -> pd.DataFramen draws of every round in rounds (round_rows: its official totals, length, ending, winner):
draw (0 .. n-1), bout_id, round, block (0 .. the round’s last), readings (blank counts where none came),
a_* / b_* (the 22 counts), as fight_blocks has the live feed’s; and after each round but the fight’s last,
the break: rows (round + 1, block -2 / -1) holding what the feed posted in it (what came after the round’s
last reading, then its corrections). Seeded: the same rounds in the same order draw the same.
to_json
to_json() -> dict[str, Any]training_cards
training_cards(inputs: StatsInputs) -> set[str]The cards a fit learns from: every card with a round Cito read (a dead feed’s not).
Functions
break_readings
break_readings(ticks: pd.DataFrame, blocks: pd.DataFrame, R: pd.DataFrame) -> pd.DataFrameWhat the live feed posted between rounds - its corrections to the round just fought, shown in the break (no fight goes on in it): bout_id, round (the coming round, the one whose bell ends the break), block (-1: its last 30 s before the bell, -2: the break before them), readings, a_* / b_* (their counts summed). The break: from the round before’s end + LATE_S (fight_blocks’ last) to the bell, both rounds clocked by Cito; before the first bell (or after a round Cito did not clock) the minute before the bell. The round before ends where fight_blocks stops taking it (its last block’s end - the clock’s stops in it - + LATE_S): no reading in both.
ko_readings
ko_readings(ticks: pd.DataFrame, blocks: pd.DataFrame, R: pd.DataFrame) -> pd.DataFrameHOW THE LIVE FEED SHOWED A KO ROUND, reading by reading (11-19: the simulator’s own timing showed a finish coming more
than the real feed does - the information test): for every KO round Cito read (a winner known, the feed alive), each live
reading’s clock and what it added - the winner’s and the loser’s significant strikes landed / attempted (w_ / l_), the
winner’s knockdowns, and each of the other totals: bout_id, round, L, clock_s, w_* / l_* (KO_COUNTS; a count the feed
took back: 0). The simulator times a KO round’s strikes and knockdowns by one of these, and takes from the same round how
much of the official totals its feed showed at all.
ko_shapes
ko_shapes(finishes: pd.DataFrame, rounds: pd.DataFrame | None = None, min_readings: int = 3) -> list[dict[str, Any]]The real KO rounds’ courses (StatsParams.ko_shapes) from their readings (ko_readings; rounds: only these
rounds’, and with their official totals each course’s err_w / err_l - what the feed showed of the round in all less
the official, the winner’s and the loser’s 22 counts (the target / position splits 0: rescaled with the strikes)): a round
with fewer than min_readings readings or no strike shown is no course.
live_totals
live_totals(blocks: pd.DataFrame) -> pd.DataFrameEach round’s live totals: the sum of its blocks (a_* / b_*).
reading_clocks
reading_clocks(ticks: pd.DataFrame, blocks: pd.DataFrame, R: pd.DataFrame) -> pd.DataFrameEvery live reading with counts inside a round Cito clocked, as fight_blocks takes them (from the bell to the round’s end + its clock’s stops + LATE_S): bout_id, round, clock_s (its clock; without one, the seconds since the bell less the stops by then).
refit_stats_simulator
refit_stats_simulator(db: DBClient, holdout_cards: int = 4) -> dict[str, Any]The refit ON DEMAND (Sam 11-19: never on a cadence - when enough new cards are in): a candidate fitted on every round
Cito read but the latest holdout_cards cards’ scored on those against the saved simulator; it must pass the purged gate
(assess) and score better (lower crps) - then refitted on every round and saved; else the saved one stays. Writes the
round rows (version ”) to features.simulator_rounds.
repair
repair(X: np.ndarray) -> np.ndarrayWhole counts that hold their hierarchy (…, 22): positions’ landed <= attempted, sig = their sum, the targets summing to sig (landed, attempted), total >= sig, takedowns landed <= attempted.
round_rows
round_rows(official: pd.DataFrame, bouts: pd.DataFrame, blocks: pd.DataFrame | None = None) -> pd.DataFrameOne row per round: bout_id, event_id, date, round, L (its length, s), n (its blocks), end (‘full’: to the horn / ‘ko’ / ‘sub’ / ‘other’ finish), win (the winner: 0 A, 1 B, -1 none), the official a_* / b_* (A = the fight’s fighter_a; a stoppage at 5:00 - between rounds - is the horn, a submission at 5:00 a finish); with the live blocks: cito (Cito read it), lines (every block it saw from the lines), last_seen (its last block had a reading), dead (Cito clocked it, no reading came: the feed down). A round missing a count is left out.
score_new_cards
score_new_cards(db: DBClient) -> dict[str, Any]The job’s step after a card (Sam 11-19): the saved stats simulator scored on every round Cito read dated after it was saved and not yet scored by it (walk-forward - never a refit here), the rows written to features.simulator_rounds.
sofar_scores
sofar_scores(real: pd.DataFrame, sim: pd.DataFrame, R: pd.DataFrame, fields: list[str], seed: int = 0) -> pd.DataFrameEach real block’s so-far count (the round’s live counts through the block, a blank block 0) against the simulated rounds’ (every draw), per fighter and count: crps, pit (randomized for ties), in50 / in80; last: the round’s last block (the round’s live total).
structure
structure(blocks: pd.DataFrame, R: pd.DataFrame) -> dict[str, Any]The shape of a set of live rounds (real or simulated: their draws pooled), the numbers the simulator is fitted to and the test compares: each count’s share by block (full rounds, every block seen); its dispersion against an even-chance split, block-to-block carry-over, A and B together; control spells (count, longest, a takedown at the start); strikes by who held control; a KO’s knockdowns and flurry, a submission’s end; empty blocks, control over 30 s / below 0 in a block.
without
without(inputs: StatsInputs, bouts: set[str]) -> StatsInputsinputs with bouts taken out of every part (a held-out card: nothing of it reaches the fit).