hits-v1: built on the right structure, measured honestly, REFUTED
Hits was diagnosed as a family mismatch: 84% of hits rows trade at 0.5, so the stat rides on P(0), and a negative binomial has unbounded support and no notion of opportunity at all. hits-v1 models it as the bounded conversion it is -- N ~ the player's empirical at-bat distribution, hits|N ~ Binomial(N,q), with the multiplier scaling q (conversion) and never N (opportunity). STEP 0 confirmed the inputs before the model existed: 30/30 real ledger players, 100% combined-input coverage. Every read goes through knownRate -- a row with no atBats is dropped, never counted as a 0-at-bat game. It FIRES: 158/159 hits props (99.4%) on the live production snapshot, through the real attachProjection path. Scoping by book IDENTITY rather than price shape kept 94 out-of-promotion-band props on the board, 93 of them modelled -- 59% that a price rule would have deleted. And it LOST. Point-in-time replay (game log truncated strictly before each row's game_date, real grade-time multiplier), hits-only, direction-aligned, n=242: resolution champion 0.195 / ladder 0.048 / hits-v1 0.026. Paired bootstrap on the same rows: hits-v1 - ladder = -0.022, CI95 excluding zero. Not promoted. The value is in what it eliminates. The family was wrong AND the mean was not the constraint -- hits-v1 moved the line-0.5 mean 0.554 -> 0.581 toward a 0.598 base rate while resolution fell. What is left is per-prop discrimination: the ladder's inputs, not its distribution. The pre-registered fallback is recorded as WRONG rather than deleted. It said hits might be genuinely low-resolution for anyone; the champion scores 0.276 on the identical 189 rows, so there is real signal and the ceiling claim was the comfortable reading, not the honest one. Its own control refuted it, and that control was already in hand when the branch was written. hits-v1 stays wired as a challenger writing its own ledger columns so the forward accrual can confirm the backtest. Champion, ladder, ranking, calibration, reference ruler and the four accruing verdicts are byte-identical -- the diff has zero deleted lines. Tests 4,156 green (332 suites); web build exit 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W1sivYNqY2TS5ftykmHBU9
This commit is contained in:
@@ -161,3 +161,70 @@ describe('attachProjection — champion byte-identical', () => {
|
||||
expect(out[0].proj_point).not.toBeNull(); // projected even with no game log
|
||||
});
|
||||
});
|
||||
|
||||
describe('hits-v1 — the challenger rides alongside, and reads the RIGHT takeable axis', () => {
|
||||
// A real log: at-bat counts AND hits, which the negative-binomial path never
|
||||
// asks for. Most recent LAST (statsapi order).
|
||||
const abLog = (pairs) => pairs.map(([ab, h]) => ({ isHome: true, opponent: 'Boston Red Sox', stat: { atBats: ab, hits: h } }));
|
||||
const LOG = abLog([[4, 1], [3, 0], [5, 2], [4, 1], [4, 0], [3, 1], [4, 2], [4, 1], [3, 1], [4, 0]]);
|
||||
|
||||
it('emits proj_hits_p_over WITHOUT disturbing the current ladder or the champion', () => {
|
||||
const grade = { stat_type: 'hits', line: 0.5, direction: 'over', season_avg: 0.9, fair_prob: 0.55, team: 'NYY', book: 'draftkings', over_odds: -150, under_odds: 130 };
|
||||
const withHits = pc.projectProp({ grade, gameLog: LOG });
|
||||
// The ladder value is computed from the SAME log by the SAME code path as
|
||||
// before this challenger existed — hits-v1 is additive, never substitutive.
|
||||
expect(withHits.proj_hits_p_over).toBeGreaterThan(0);
|
||||
expect(withHits.proj_hits_p_over).toBeLessThanOrEqual(1);
|
||||
expect(withHits.proj_p_over_line).not.toBeNull();
|
||||
expect(withHits.proj_distribution.family).toBe('negative_binomial');
|
||||
expect(withHits.proj_hits_meta.version).toBe('hits-v1');
|
||||
expect(withHits.proj_hits_meta.family).toBe('binomial_over_empirical_at_bats');
|
||||
});
|
||||
|
||||
it('MODELS a -300 one-sided hits market — takeable by identity, outside the promotion band', () => {
|
||||
// The whole reason the three questions were disambiguated. A -300 hits-over
|
||||
// from a real book is a bet you can place: steep juice is a PRICE, not a
|
||||
// disqualification, and one-sidedness is normal baseball market structure.
|
||||
const grade = { stat_type: 'hits', line: 0.5, direction: 'over', season_avg: 0.9, team: 'NYY', book: 'betrivers', over_odds: -300, under_odds: null };
|
||||
const p = pc.projectProp({ grade, gameLog: LOG });
|
||||
expect(p.proj_hits_p_over).not.toBeNull(); // MODELLED, not thrown away
|
||||
const m = p.proj_hits_meta.market;
|
||||
expect(m.market_takeable).toBe(true); // identity: yes
|
||||
expect(m.within_promotion_band).toBe(false); // price band: no
|
||||
expect(m.one_sided).toBe(true); // normal, not an error
|
||||
expect(m.price_filtered).toBe(false); // no price-shape gate ran
|
||||
});
|
||||
|
||||
it('a longshot +1300 hits market is still modelled — recording is not crowning', () => {
|
||||
const grade = { stat_type: 'hits', line: 2.5, direction: 'over', season_avg: 0.9, team: 'NYY', book: 'fanduel', over_odds: 1300, under_odds: -2000 };
|
||||
const p = pc.projectProp({ grade, gameLog: LOG });
|
||||
expect(p.proj_hits_p_over).not.toBeNull();
|
||||
expect(p.proj_hits_meta.market.market_takeable).toBe(true);
|
||||
expect(p.proj_hits_meta.market.within_promotion_band).toBe(false);
|
||||
});
|
||||
|
||||
it('never reads the deprecated `takeable` mirror', () => {
|
||||
const src = require('fs').readFileSync(require.resolve('../../src/services/projection/binomialHits'), 'utf8')
|
||||
+ require('fs').readFileSync(require.resolve('../../src/services/projectionChallenger'), 'utf8');
|
||||
// The disambiguated names only. `takeable:` as a bare field read would be
|
||||
// the ambiguous mirror the S-prior commit deprecated.
|
||||
expect(/\btakeable\s*:/.test(src.replace(/market_takeable\s*:/g, ''))).toBe(false);
|
||||
});
|
||||
|
||||
it('is NULL on a non-hits prop — never a fabricated 0', () => {
|
||||
const grade = { stat_type: 'total_bases', line: 1.5, direction: 'over', season_avg: 1.4, team: 'NYY', book: 'draftkings', over_odds: -110 };
|
||||
const p = pc.projectProp({ grade, gameLog: LOG });
|
||||
expect(p.proj_hits_p_over).toBeNull();
|
||||
expect(p.proj_hits_meta).toBeNull();
|
||||
});
|
||||
|
||||
it('abstains honestly when the at-bat inputs are underivable, keeping the ladder', () => {
|
||||
// A log with hits but no at-bat counts — exactly what the NB path runs on.
|
||||
const noAb = [1, 0, 2, 1, 1, 0, 1].map((h) => ({ isHome: true, opponent: 'Boston Red Sox', stat: { hits: h } }));
|
||||
const grade = { stat_type: 'hits', line: 0.5, direction: 'over', season_avg: 0.9, team: 'NYY', book: 'draftkings', over_odds: -140 };
|
||||
const p = pc.projectProp({ grade, gameLog: noAb });
|
||||
expect(p.proj_hits_p_over).toBeNull(); // no read, not a zero
|
||||
expect(p.proj_hits_meta.reason).toBe('inputs_underivable');
|
||||
expect(p.proj_p_over_line).not.toBeNull(); // the ladder still stands
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user