Recency-weighted v4 model: fast-Elo blend, Team-DC majority, nightly refit

Validated on the strict 2018-2022 window and confirmed on the untouched
2022-2026 test set (RPS 0.1703 vs 0.1721 over 4,448 matches):
- the Elo member now blends 30% of a 3x-faster Elo walk, so recent
  results move ratings much harder
- ensemble weight shifts from 75/25 toward Elo to 45/55 toward the
  time-decayed Team-DC member — the recent-form model now leads
- Team-DC refits nightly (and at boot) on the 15-year window plus every
  finished 2026 match, via a new committed-at-build dcTrain.json
  (server-only, excluded from the PWA precache)
- a recent-form goal multiplier was also tested and did NOT validate;
  it ships disabled, and backtest.json records the whole decision

buildBacktest.ts grew the experiment harness: wider xi/k grids, the
fast-Elo and form variants, a pre-registered ship bar (>=0.0005
validation RPS), and a 7-day refit-cadence check. Older ratings.json
files still work — all new model fields are optional with golden
regression coverage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 23:34:18 +02:00
parent a3f529746f
commit d3e8df96ef
10 changed files with 379 additions and 39 deletions
+33 -1
View File
@@ -1,7 +1,7 @@
import { describe, it, expect } from 'vitest';
import { expectedHome, eloDelta, goalDiffMultiplier } from './elo';
import { poissonPmf, scoreMatrix, outcomeProbs, lambdasFromElo, type ModelParams } from './poisson';
import { predictMatch, knockoutAdvanceProb, type RatingsModel } from './predict';
import { blendedRating, predictMatch, knockoutAdvanceProb, type RatingsModel } from './predict';
const PARAMS: ModelParams = { goalsPerElo: 0.0057, avgGoals: 2.73, rho: -0.05, homeAdvElo: 70 };
@@ -82,3 +82,35 @@ describe('predictMatch', () => {
expect(adv).toBeLessThan(1);
});
});
describe('fast-Elo blend (v4 recency)', () => {
const base: RatingsModel = {
asOf: '2026-06-10',
params: PARAMS,
ratings: { Strong: 2050, Weak: 1650 },
};
it('absent fast fields ⇒ bit-identical to the slow model (golden regression)', () => {
const withNoise: RatingsModel = { ...base, ratingsFast: { Strong: 2300, Weak: 1400 }, fastBeta: 0 };
const a = predictMatch('Strong', 'Weak', base);
const b = predictMatch('Strong', 'Weak', withNoise);
expect(b.probs).toEqual(a.probs);
expect(b.lambdaHome).toBe(a.lambdaHome);
});
it('blends toward the fast rating with β', () => {
expect(blendedRating({ ...base, ratingsFast: { Strong: 2150, Weak: 1650 }, fastBeta: 0.3 }, 'Strong'))
.toBeCloseTo(0.7 * 2050 + 0.3 * 2150, 9);
});
it('a hot fast rating raises the win probability', () => {
const hot: RatingsModel = { ...base, ratingsFast: { Strong: 2250, Weak: 1650 }, fastBeta: 0.3 };
expect(predictMatch('Strong', 'Weak', hot).probs.home)
.toBeGreaterThan(predictMatch('Strong', 'Weak', base).probs.home);
});
it('falls back to DEFAULT_ELO for unknown teams in the fast walk', () => {
const m: RatingsModel = { ...base, ratingsFast: {}, fastBeta: 0.3 };
expect(blendedRating(m, 'Strong')).toBeCloseTo(0.7 * 2050 + 0.3 * 1500, 9);
});
});
+18 -1
View File
@@ -19,6 +19,14 @@ export interface RatingsModel {
teamDc?: TeamDcParams;
/** Log-pool weight on the Elo-DC member (backtest-tuned). */
ensembleW?: number;
/** Fast Elo member — the same walk at K×fastM, so recent results move it
* harder. Blended into the Elo member as (1−β)·slow + β·fast. All optional:
* an older ratings file behaves exactly as before. */
ratingsFast?: Record<string, number>;
fastBeta?: number;
fastM?: number;
/** Team-DC fit hyper-params, shipped so the server can refit in-tournament. */
teamDcFit?: { xi: number; shrinkK: number; windowYears: number };
}
export const DEFAULT_ELO = 1500;
@@ -27,6 +35,15 @@ export function ratingOf(model: RatingsModel, team: string): number {
return model.ratings[team] ?? DEFAULT_ELO;
}
/** The rating that drives probabilities: slow Elo blended with the fast walk
* when the model ships one (backtest-validated recency component). */
export function blendedRating(model: RatingsModel, team: string): number {
const slow = model.ratings[team] ?? DEFAULT_ELO;
const beta = model.fastBeta ?? 0;
if (beta <= 0 || !model.ratingsFast) return slow;
return (1 - beta) * slow + beta * (model.ratingsFast[team] ?? DEFAULT_ELO);
}
export interface MatchPrediction {
home: string;
away: string;
@@ -52,7 +69,7 @@ export function matchMatrix(
homeAdv = 0,
): number[][] {
const { lambdaHome, lambdaAway } = lambdasFromElo(
ratingOf(model, home), ratingOf(model, away), model.params, homeAdv,
blendedRating(model, home), blendedRating(model, away), model.params, homeAdv,
);
const mElo = scoreMatrix(lambdaHome, lambdaAway, model.params.rho);
if (!model.teamDc || model.ensembleW == null || model.ensembleW >= 1) return mElo;