betting_combat.features.final
final — the main feature table (Sam 2026-11-13, spec docs/FINAL_TABLE.md): one row per fight per
break, both fighters, everything known at that moment. Break 0 is the bell of round 1; break k the
minute after round k. The answers are features.labels (the same keys).
Blocks ({block}_{side}_{stat}; side a = our fighter A, b, d = A - B, lr = log(A / B) for the
per-minute volumes, x_a / x_b / xd = the matchups: A’s attack against B’s defence and back):
keys bout_id, brk, date, bout_order, event_id, fighter_a_id, fighter_b_id, rounds_done,
upcoming_round, rounds_left, scheduled_rounds, upcoming
fight_ the fight (features.fight: card, division, title, five rounds, venue, priors)
prof_ each fighter’s profile as of the day (features.profile) and his outside record
since his debut (features.career)
hist_ each fighter’s history (history.fight_history: lines over four windows, rounds,
record, shape, sequence, opponent-adjusted, styles)
mkt_ each against the books in his earlier fights (history.market_history)
x_ the matchups on the history (c and e3), and body / age / stance / style pairs
book_ this fight’s prices (features.book: the books’ close before the card)
up_ the round about to start (u = k + 1): each fighter’s round-u typical, its matchups, how
often he reaches it, the books’ chances for round u
prev_ the round just fought (k), as live sees it at the bell (inplay), each fighter’s,
A - B, against his own round-k typical (vs_typ) and against what the opponent
typically allows in round k (vs_opp); zeros at break 0
sofar_ rounds 1..k the same, against the typicals through k rounds, momentum, pace against
both fighters’ expected pace; zeros at break 0
Kalshi and Polymarket are not here (2024+ only): features.market, for sizing.
No blanks: a rate the round does not define (no takedown to control on) is the fighter’s typical for it (its vs_typ 0); this fight’s prices missing are Elo’s (the close) or the earlier years’ medians; every other gap the earlier years’ medians.
Stored as features.final_pNN (500 columns each: a row must fit one Postgres page), each part keyed
bout_id + brk; FinalTable.read joins them back.
Classes
FinalFills
Bases: FeatureTable
features.final_fills: the final table’s fill for a blank, per year and column (fill_table
of the build’s rows before the fill), long: year, col, value. The card run fills a live row’s blanks
from it exactly as the build filled the stored rows.
read_table
read_table(db: DBClient) -> pd.DataFrameThe fill table back: years down, columns across.
write_table
write_table(db: DBClient, table: pd.DataFrame) -> dict[str, int]FinalInputs
What the build reads: fighter_stats, the fight table, profile, career, book, labels.
read
read(db: DBClient) -> FinalInputsFinalTable
Bases: FeatureTable
features.final (stored in parts final_pNN): the main feature table (module doc).
build
build(db: DBClient, base: Base | None = None) -> dict[str, int]Every row; the stored parts dropped first (a build’s columns may differ from the last one’s: a column moving to another part would stay behind in its old one, twice in a read - 11-19).
compute
compute(base: Base) -> pd.DataFrameassemble’s rows; the fill table kept (fills: written with the rows, the card run’s).
parts
parts(columns: list[str]) -> list[list[str]]The stored parts’ columns (each with the key and date), in block order.
pick
pick(rows: pd.DataFrame, name: str = SELECTION) -> pd.DataFramerows (this table’s) cut to the key, the date and the selection’s columns.
read
read(db: DBClient, since: dt.date | None = None, columns: list[str] | None = None) -> pd.DataFrameThe table back (its parts joined); columns: only these (with the key and the date).
selection
selection(name: str = SELECTION) -> dict[str, list[str]]A saved feature selection (features/selection/{name}.json): final - this table’s
columns it keeps, dataset - Dataset 1 v2’s (today’s primary inputs) it keeps. Default:
López on this table + today’s 198 (2026-11-13, 4,167 + 156).
update
update(db: DBClient, since: dt.date, base: Base | None = None) -> dict[str, int]The rows dated since on - only when the build’s columns are the stored ones (else a build is needed).
write
write(db: DBClient, rows: pd.DataFrame) -> dict[str, int]Prepared
Everything a set of rows’ blocks need that is known before their fights’ first bell
(prepare): each appearance (A), its round-k and through-k typicals (RT, TT), the
division’s rates (divR), the fight-level blocks by bout, the books.
Functions
assemble
assemble(inp: FinalInputs, start: pd.Timestamp = START, view: LiveView | None = None) -> pd.DataFrameThe final table’s rows and every block (module doc).
blocks
blocks(prep: Prepared, rows: pd.DataFrame, inplay: pd.DataFrame) -> pd.DataFramerows with every block (module doc), blanks left (fill_from fills them): the fight-level
blocks, round u’s, the round just fought and the fight so far (inplay: breaks’ rows).
fill_from
fill_from(X: pd.DataFrame, dates: pd.Series, table: pd.DataFrame) -> pd.DataFrameX’s remaining blanks filled from table (fill_table), each row by its year (a year past
the table’s last: its last row, every stored year’s medians); a column the table lacks 0.
fill_table
fill_table(X: pd.DataFrame, dates: pd.Series, columns: pd.Index | list[str] | None = None) -> pd.DataFramePer year, each numeric column’s fill: the median of the yearly medians of the strictly earlier
years (0 where no earlier year told it), and one row more for the year after the last (every year’s).
columns: the ones to compute (default every numeric).
prepare
prepare(inp: FinalInputs, rows: pd.DataFrame) -> PreparedPrepared for rows (_rows’ shape): the history of every appearance (the fights to
come among rows included), the fight-level blocks of rows’ fights.
unfilled
unfilled(inp: FinalInputs, start: pd.Timestamp = START, view: LiveView | None = None) -> pd.DataFrameThe final table’s rows and every block before the fill (assemble fills them).