Default window 2 weeks (1-week option added) on the site, best week and what-if; new-song backtest takes the window (--w, default 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 12:32:28 +00:00
co-authored by Claude Opus 5.5
parent 37b3029e02
commit 0e511e1e0b
6 changed files with 114 additions and 107 deletions
+15 -12
View File
@@ -125,7 +125,7 @@ svg text { fill: var(--muted); font-size: 11px; }
<div class="controls">
<div class="ctl">Release week <b id="hlabel">—</b><input type="range" id="h" min="0" max="25" value="0"></div>
<div class="ctl">Added within
<select id="w"><option value="2">2 weeks</option><option value="4">4 weeks</option><option value="6">6 weeks</option><option value="8" selected>8 weeks</option><option value="10">10 weeks</option><option value="12">12 weeks</option></select>
<select id="w"><option value="1">1 week</option><option value="2" selected>2 weeks</option><option value="4">4 weeks</option><option value="6">6 weeks</option><option value="8">8 weeks</option><option value="10">10 weeks</option><option value="12">12 weeks</option></select>
</div>
<div class="ctl">Station
<select id="ch">
@@ -170,7 +170,7 @@ svg text { fill: var(--muted); font-size: 11px; }
<div class="ctl">From <input type="date" id="bw-from"></div>
<div class="ctl">To <input type="date" id="bw-to"></div>
<div class="ctl">Added within
<select id="bw-w"><option value="2">2 weeks</option><option value="4">4 weeks</option><option value="6">6 weeks</option><option value="8" selected>8 weeks</option><option value="10">10 weeks</option><option value="12">12 weeks</option></select>
<select id="bw-w"><option value="1">1 week</option><option value="2" selected>2 weeks</option><option value="4">4 weeks</option><option value="6">6 weeks</option><option value="8">8 weeks</option><option value="10">10 weeks</option><option value="12">12 weeks</option></select>
</div>
<div class="ctl">New Music Friday Denmark
<select id="bw-nmf"><option value="auto">As often as their releases were placed</option><option value="yes">Placed</option><option value="no">Not placed</option></select>
@@ -420,7 +420,7 @@ function whatIfUI(a, h) {
const d = (x, y, f) => { const v = y - x; if (Math.abs(v) < 0.005 * (f === 'p' ? 1 : 100)) return ''; return `<span class="d ${v > 0 ? 'up' : 'down'}">${v > 0 ? '+' : ''}${f === 'p' ? Math.round(v * 100) + ' pts' : Math.round(v)}</span>`; };
const rows = [['Any DR station', w.base.add_any, w.scenario.add_any]].concat(GROUPS.map(([g, l]) => [l, chanP(w.base, g), chanP(w.scenario, g)]));
const onNow = Object.keys(w.current.in_rotation || {});
$('wi-out').innerHTML = `<p class="note">${w.release ? (w.too_soon ? 'Too soon after their last release for a new-song estimate this week; the numbers below are the model\'s extrapolation.' : `A new song released the week of ${fmtDate(w.window_start)}: chance DR adds it within 8 weeks.`) : `No new release: chance of a new add from current songs in the 8 weeks from ${fmtDate(w.window_start)}.`} In rotation now on ${onNow.length ? onNow.length + ' station(s)' : 'no station'}. Now: ${w.current.t40 ? 'Track Top-40 #' + w.current.t40 : 'not on the Track Top-40'}, ${w.current.air ? 'Airplay Top-20 #' + w.current.air : 'not on the Airplay Top-20'}, ${w.current.entry == null ? 'no chart entry on record' : 'latest new chart entry ' + w.current.entry + ' weeks ago'}.</p>
$('wi-out').innerHTML = `<p class="note">${w.release ? (w.too_soon ? 'Too soon after their last release for a new-song estimate this week; the numbers below are the model\'s extrapolation.' : `A new song released the week of ${fmtDate(w.window_start)}: chance DR adds it within 2 weeks.`) : `No new release: chance of a new add from current songs in the 8 weeks from ${fmtDate(w.window_start)}.`} In rotation now on ${onNow.length ? onNow.length + ' station(s)' : 'no station'}. Now: ${w.current.t40 ? 'Track Top-40 #' + w.current.t40 : 'not on the Track Top-40'}, ${w.current.air ? 'Airplay Top-20 #' + w.current.air : 'not on the Airplay Top-20'}, ${w.current.entry == null ? 'no chart entry on record' : 'latest new chart entry ' + w.current.entry + ' weeks ago'}.</p>
<div class="kpis">${rows.map(([l, b, s]) => `<div class="kpi"><div>${l}</div><b>${pct(s)}</b>${d(b, s, 'p')}<div>was ${pct(b)}</div></div>`).join('')}
<div class="kpi"><div>Plays, first week</div><b>${Math.round(w.scenario.mean)}</b>${d(w.base.mean, w.scenario.mean, 'n')}<div>was ${Math.round(w.base.mean)}</div></div></div>`;
};
@@ -430,17 +430,20 @@ function whatIfUI(a, h) {
// ---------- model tab ----------
function renderModel() {
const sc = meta.backtest || [];
const get = (m, k) => sc.find(x => x.model === m && x.metric === k)?.value;
const ms = [['rate by in-rotation-now', 'Rate by "in rotation now"'], ['rate by last-12-weeks level', 'Rate by last-12-weeks airplay'],
['event model (pre-release: NMF from history)', 'Model, before release (as on this site)'], ['event model (post-release: NMF known)', 'Model, NMF placement known']];
const sc = (meta.backtest || []).filter(x => x.metric.startsWith('event_'));
const win = sc.length ? Math.max(...sc.map(x => x.h)) : 2;
const get = (m, k) => sc.find(x => x.model === m && x.metric === k && x.h === win)?.value;
const ms = [['rate by in-rotation-now', 'Rate by "in rotation now"'], ['rate by last-12-weeks level', 'Rate by last-12-weeks airplay'], ['release timing only', 'Release timing only'],
['model + pooled isotonic (pre-release)', 'Model before release, isotonic (any station on this site)'], ['model + pooled Platt (pre-release)', 'Model before release, Platt (per station on this site)'],
['model, NMF known (post-release)', 'Model, NMF placement known']];
const f = (v, d) => v == null || isNaN(v) ? '—' : v.toFixed(d);
const sk = get('event model', 'event_skill_any_vs_level');
$('cards').innerHTML = sc.some(x => x.metric.startsWith('event_')) ? `<div class="card"><h3>If an artist releases a new song, does DR add it within 8 weeks?</h3>
<table class="wtable"><thead><tr><th class="l"></th><th>Any station<br>log-loss</th><th>Any station<br>PR-AUC</th><th>Per station<br>PR-AUC</th></tr></thead><tbody>
${ms.map(([m, l]) => `<tr><td class="l">${l}</td><td>${f(get(m, 'event_logloss_any'), 3)}</td><td>${f(get(m, 'event_prauc_any'), 3)}</td><td>${f(get(m, 'event_prauc_ch'), 3)}</td></tr>`).join('')}
const ska = get('model + pooled isotonic (pre-release)', 'event_skill_any_vs_level'), skc = get('model + pooled Platt (pre-release)', 'event_skill_ch_vs_level');
const sign = v => `<b class="${v > 0 ? 'up' : 'down'}">${v > 0 ? '+' : ''}${f(v, 3)}</b>`;
$('cards').innerHTML = sc.length ? `<div class="card"><h3>If an artist releases a new song, does DR add it within ${win} week${win > 1 ? 's' : ''}?</h3>
<table class="wtable"><thead><tr><th class="l"></th><th>Any station<br>log-loss</th><th>Any station<br>PR-AUC</th><th>Per station<br>log-loss</th><th>Per station<br>PR-AUC</th></tr></thead><tbody>
${ms.map(([m, l]) => `<tr><td class="l">${l}</td><td>${f(get(m, 'event_logloss_any'), 3)}</td><td>${f(get(m, 'event_prauc_any'), 3)}</td><td>${f(get(m, 'event_logloss_ch'), 4)}</td><td>${f(get(m, 'event_prauc_ch'), 3)}</td></tr>`).join('')}
</tbody></table>
<p>Walk-forward over the past year: each week's releases scored by a model fitted only on releases whose outcome was already known. Skill of the before-release model vs last-12-weeks airplay: <b class="${sk > 0 ? 'up' : 'down'}">${sk > 0 ? '+' : ''}${f(sk, 3)}</b> (any station). Lower log-loss and higher PR-AUC are better; a leak test confirms no feature uses data from after the forecast week.</p></div>`
<p>Walk-forward over the past year: each week's releases scored by a model fitted only on releases whose outcome was already known, artists included only from when they were knowable. Skill vs last-12-weeks airplay: ${sign(ska)} any station, ${sign(skc)} per station. Lower log-loss and higher PR-AUC are better; a leak test confirms no feature uses data from after the forecast week.</p></div>`
: '<p class="note">No backtest stored yet (`airplay model events`).</p>';
}