ui changes and cs prices
All checks were successful
Test and deploy staging / staging (push) Successful in 11m52s

This commit is contained in:
2026-09-25 00:44:06 +00:00
parent c757d0882a
commit abac077541
200 changed files with 6236 additions and 2311 deletions

View File

@@ -43,7 +43,14 @@ export const gPresets: Record<string, Partial<GWeights>> = {
};
const SCALE = 0.55;
const POSITION_POINTS: Record<number, number> = { 1: 1, 2: 0.75, 3: 0.6, 4: 0.45, 5: 0.35, 6: 0.25 };
const POSITION_POINTS: Record<number, number> = {
1: 1,
2: 0.75,
3: 0.6,
4: 0.45,
5: 0.35,
6: 0.25
};
const positionPoints = (r: Result) => (r === 'D' ? 0 : (POSITION_POINTS[r] ?? 0.1));
const DRAW_SCORE = [0, 0.6, 0.7, 0.6, 0.45, 0.4, 0.25, 0.1, 0, -0.2, -0.3];
@@ -62,7 +69,10 @@ const mean = (xs: number[]) => xs.reduce((a, b) => a + b, 0) / xs.length;
function rawForm(h: Runner, w: GWeights): number | null {
if (h.form.length === 0) return null;
const decay = h.form.map((_, i) => Math.pow(0.5, i / w.halfLife));
return h.form.reduce((s: number, r, i) => s + decay[i] * positionPoints(r), 0) / decay.reduce((a, b) => a + b, 0);
return (
h.form.reduce((s: number, r, i) => s + decay[i] * positionPoints(r), 0) /
decay.reduce((a, b) => a + b, 0)
);
}
export function gFeatures(runners: Runner[], w: GWeights): GFeatures[] {
@@ -89,7 +99,14 @@ export function gFeatures(runners: Runner[], w: GWeights): GFeatures[] {
// debutanten: geen bewijs dat ze in de draf blijven
const base = h.form.length === 0 ? 0.12 : 0.03;
const pFail = Math.min(0.5, base + 0.1 * disq + 0.03 * poor);
return { form: pick('form'), speed: pick('speed'), level: pick('level'), draw: DRAW_SCORE[h.n] ?? 0, pFail, estimated };
return {
form: pick('form'),
speed: pick('speed'),
level: pick('level'),
draw: DRAW_SCORE[h.n] ?? 0,
pFail,
estimated
};
});
}
@@ -117,9 +134,19 @@ export type GPrediction = {
export function gPredict(runners: Runner[], w: GWeights): GPrediction[] {
if (runners.length === 0) return [];
const feats = gFeatures(runners, w);
const z = Object.fromEntries(gFeatureKeys.map((k) => [k, zscores(feats.map((f) => f[k]), SD_FLOOR[k])])) as Record<GFeatureKey, number[]>;
const z = Object.fromEntries(
gFeatureKeys.map((k) => [
k,
zscores(
feats.map((f) => f[k]),
SD_FLOOR[k]
)
])
) as Record<GFeatureKey, number[]>;
const rows = runners.map((horse, i) => {
const contributions = Object.fromEntries(gFeatureKeys.map((k) => [k, w[k] * z[k][i] * SCALE])) as Record<GFeatureKey, number>;
const contributions = Object.fromEntries(
gFeatureKeys.map((k) => [k, w[k] * z[k][i] * SCALE])
) as Record<GFeatureKey, number>;
const riskPenalty = w.risk * Math.log(1 - feats[i].pFail);
const logit = Object.values(contributions).reduce((a, b) => a + b, 0) + riskPenalty;
return { horse, features: feats[i], contributions, riskPenalty, logit, p: 0 };