Next week page: relative certainty (vs an average artist), tail-corrected 1-week chances, track record shows only bands with 30+ forecasts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+29
-20
@@ -131,10 +131,10 @@ svg text { fill: var(--muted); font-size: 11px; }
|
||||
.cert.c1 { background: color-mix(in srgb, var(--good) 12%, var(--panel)); color: var(--good); }
|
||||
.cert.c2 { background: var(--accent-soft); color: var(--accent); }
|
||||
.cert.c3, .cert.c4 { background: var(--bg); color: var(--muted); }
|
||||
.dots { display: flex; align-items: center; gap: 4px; }
|
||||
.dots span { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--accent); }
|
||||
.dots span.f { background: var(--accent); }
|
||||
.dots em { font-style: normal; color: var(--muted); font-size: 13px; margin-left: 8px; }
|
||||
.rel { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; color: var(--muted); }
|
||||
.rel .track2 { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
|
||||
.rel .track2 i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
|
||||
.rel b { color: var(--ink); }
|
||||
.chs { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.chs span { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: color-mix(in srgb, var(--c) 14%, var(--panel)); color: var(--ink); }
|
||||
.live { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
|
||||
@@ -498,7 +498,10 @@ function renderModel() {
|
||||
// ---------- next week ----------
|
||||
let nw = null, nwFilter = 'all', nwGroup = 'any';
|
||||
const GROUP_C = { P3: 'var(--p3)', P4: 'var(--p4)', P5: 'var(--p5)', P6: 'var(--p6)', P8: 'var(--p8)' };
|
||||
const certainty = p => p >= 0.7 ? [0, 'Very likely'] : p >= 0.4 ? [1, 'Likely'] : p >= 0.2 ? [2, 'Possible'] : p >= 0.1 ? [3, 'Long shot'] : [4, 'Outside chance'];
|
||||
// A single week is a narrow window (an average artist: about 0.3%), so certainty is shown against
|
||||
// that: how many times an average artist's chance.
|
||||
let nwBase = 0.003;
|
||||
const certainty = p => { const m = p / nwBase; return m >= 25 ? [0, 'Top pick'] : m >= 15 ? [1, 'Strong'] : m >= 8 ? [2, 'Contender'] : [3, 'Outside chance']; };
|
||||
const oneIn = p => p >= 0.5 ? `${Math.round(p * 10)} in 10` : `1 in ${Math.max(2, Math.round(1 / p))}`;
|
||||
const fmtLong = s => new Date(s + 'T00:00:00Z').toLocaleDateString('en-GB', { day: 'numeric', month: 'long', timeZone: 'UTC' });
|
||||
const plusDays = (s, d) => { const x = new Date(s + 'T00:00:00Z'); x.setUTCDate(x.getUTCDate() + d); return x.toISOString().slice(0, 10); };
|
||||
@@ -522,21 +525,25 @@ function renderNext() {
|
||||
const end = plusDays(d.week, 6), t = d.track || {};
|
||||
// Track record: bins of the walk-forward test of exactly this forecast.
|
||||
const bins = []; let lo = 0;
|
||||
d.bins.forEach((hi, i) => { if (t[`any_bin${i}_n`]) bins.push({ lo, hi, n: t[`any_bin${i}_n`], pred: t[`any_bin${i}_pred`], obs: t[`any_bin${i}_obs`] }); lo = hi; });
|
||||
const showcase = bins.filter(b => b.lo >= 0.2).sort((a, b) => b.n - a.n)[0] || bins[bins.length - 1];
|
||||
const veryLikely = d.list.filter(x => x.p >= 0.7).length, likely = d.list.filter(x => x.p >= 0.4).length;
|
||||
// Bands with fewer than 30 past forecasts say nothing yet; left out.
|
||||
d.bins.forEach((hi, i) => { if (t[`any_bin${i}_n`] >= 30) bins.push({ lo, hi, n: t[`any_bin${i}_n`], pred: t[`any_bin${i}_pred`], obs: t[`any_bin${i}_obs`] }); lo = hi; });
|
||||
const pct1 = p => (p * 100).toFixed(p < 0.1 ? 1 : 0) + '%';
|
||||
// The track record shown up front: the highest band with enough forecasts to mean something.
|
||||
const showcase = bins.filter(b => b.n >= 200 && b.lo > 0).sort((a, b) => b.lo - a.lo)[0] || bins[0];
|
||||
nwBase = t.any_rate || 0.003;
|
||||
const top10 = d.list.slice(0, 10).reduce((s, x) => s + x.p, 0), pmax = Math.max(...d.list.map(x => x.p), 0.01);
|
||||
const groups = ['P3', 'P4', 'P5', 'P6', 'P8'];
|
||||
const enrich = x => { const gs = Object.entries(x.groups).map(([g, v]) => ({ group: g, ...v })).sort((a, b) => b.p - a.p); return { ...x, gs, best: gs[0] }; };
|
||||
let list = d.list.map(enrich);
|
||||
if (nwFilter === 'new') list = list.filter(x => !x.seasonal); else if (nwFilter === 'seasonal') list = list.filter(x => x.seasonal);
|
||||
if (nwGroup !== 'any') list = list.filter(x => x.groups[nwGroup]).sort((a, b) => b.groups[nwGroup].p - a.groups[nwGroup].p);
|
||||
const card = x => {
|
||||
const p = nwGroup === 'any' ? x.p : x.groups[nwGroup].p, [ci, cl] = certainty(p), filled = Math.round(p * 10);
|
||||
const p = nwGroup === 'any' ? x.p : x.groups[nwGroup].p, [ci, cl] = certainty(p);
|
||||
const g = nwGroup === 'any' ? x.best : { group: nwGroup, ...x.groups[nwGroup] };
|
||||
return `<div class="cc" data-id="${esc(x.id)}">
|
||||
<div class="top"><div class="nm">${esc(x.name)}<small>${x.danish ? 'Danish' : 'International'}${x.seasonal ? ' · <span class="tag2">Seasonal return</span>' : ''}</small></div>
|
||||
<div class="big"><b>${pct(p)}</b><br><span class="cert c${ci}">${cl}</span></div></div>
|
||||
<div class="dots">${Array.from({ length: 10 }, (_, i) => `<span class="${i < filled ? 'f' : ''}"></span>`).join('')}<em>${oneIn(p)}</em></div>
|
||||
<div class="rel"><div class="track2"><i style="width:${Math.min(100, 100 * p / pmax)}%"></i></div><span><b>${oneIn(p)}</b> · ${Math.round(p / nwBase)}× an average artist</span></div>
|
||||
<div class="chs">${x.gs.filter(v => v.p >= 0.01).map(v => `<span style="--c:${GROUP_C[v.group]}">${v.group} ${pct(v.p)}</span>`).join('') || '<span style="--c:var(--line)">no single station stands out</span>'}</div>
|
||||
${liveLine(g)}
|
||||
${x.song ? `<div class="note">Playing now: <b>${esc(x.song.title)}</b> (${x.song.plays} plays on DR this week)</div>` : ''}
|
||||
@@ -544,15 +551,17 @@ function renderNext() {
|
||||
};
|
||||
const chart = () => {
|
||||
if (!bins.length) return '<p class="note">No track record stored yet (`airplay model nextweek`).</p>';
|
||||
const W = 320, H = 240, P = 36, X = v => P + v * (W - P - 10), Y = v => H - P - v * (H - P - 10);
|
||||
// Zoomed to the range the forecasts use (a single week: mostly under 15%).
|
||||
const top = Math.min(1, Math.max(0.15, ...bins.map(b => Math.max(b.pred, b.obs) * 1.25)));
|
||||
const W = 320, H = 240, P = 44, X = v => P + v / top * (W - P - 10), Y = v => H - P - v / top * (H - P - 10);
|
||||
const maxn = Math.max(...bins.map(b => b.n));
|
||||
return `<svg viewBox="0 0 ${W} ${H}" width="100%" role="img" aria-label="Predicted against what happened">
|
||||
<line x1="${X(0)}" y1="${Y(0)}" x2="${X(1)}" y2="${Y(1)}" stroke="var(--line)" stroke-dasharray="4 4"/>
|
||||
<line x1="${X(0)}" y1="${Y(0)}" x2="${X(1)}" y2="${Y(0)}" stroke="var(--muted)"/><line x1="${X(0)}" y1="${Y(0)}" x2="${X(0)}" y2="${Y(1)}" stroke="var(--muted)"/>
|
||||
${[0, .25, .5, .75, 1].map(v => `<text x="${X(v)}" y="${H - P + 16}" text-anchor="middle">${v * 100}%</text><text x="${P - 6}" y="${Y(v) + 4}" text-anchor="end">${v * 100}%</text>`).join('')}
|
||||
<line x1="${X(0)}" y1="${Y(0)}" x2="${X(top)}" y2="${Y(top)}" stroke="var(--line)" stroke-dasharray="4 4"/>
|
||||
<line x1="${X(0)}" y1="${Y(0)}" x2="${X(top)}" y2="${Y(0)}" stroke="var(--muted)"/><line x1="${X(0)}" y1="${Y(0)}" x2="${X(0)}" y2="${Y(top)}" stroke="var(--muted)"/>
|
||||
${[0, .25, .5, .75, 1].map(f => f * top).map(v => `<text x="${X(v)}" y="${H - P + 16}" text-anchor="middle">${Math.round(v * 100)}%</text><text x="${P - 6}" y="${Y(v) + 4}" text-anchor="end">${Math.round(v * 100)}%</text>`).join('')}
|
||||
<text x="${(W + P) / 2}" y="${H - 2}" text-anchor="middle">we predicted</text>
|
||||
<text x="10" y="${(H - P) / 2}" text-anchor="middle" transform="rotate(-90 10 ${(H - P) / 2})">it happened</text>
|
||||
${bins.map(b => `<circle cx="${X(b.pred)}" cy="${Y(b.obs)}" r="${3 + 9 * Math.sqrt(b.n / maxn)}" fill="var(--accent)" fill-opacity=".75"><title>${Math.round(b.lo * 100)}-${Math.round(b.hi * 100)}%: predicted ${pct(b.pred)}, happened ${pct(b.obs)} (${b.n} forecasts)</title></circle>`).join('')}
|
||||
<text x="8" y="${(H - P) / 2}" text-anchor="middle" transform="rotate(-90 8 ${(H - P) / 2})" dy="-2">it happened</text>
|
||||
${bins.filter(b => b.pred <= top && b.obs <= top).map(b => `<circle cx="${X(b.pred)}" cy="${Y(b.obs)}" r="${3 + 9 * Math.sqrt(b.n / maxn)}" fill="var(--accent)" fill-opacity=".75"><title>${Math.round(b.lo * 100)}-${Math.round(b.hi * 100)}%: predicted ${pct1(b.pred)}, happened ${pct1(b.obs)} (${b.n} forecasts)</title></circle>`).join('')}
|
||||
</svg>`;
|
||||
};
|
||||
$('nw').innerHTML = `
|
||||
@@ -562,8 +571,8 @@ function renderNext() {
|
||||
<p class="note">The chance each artist enters rotation on a DR music channel that week: a new song, or plays jumping well above their usual level. Forecast made ${fmtLong(d.made_at.slice(0, 10))} from DR's artist pages up to the week of ${fmtLong(d.origin_week)}; the live lines use every DR play logged since ${fmtLong(plusDays(d.this_monday, -7))}.</p></div>
|
||||
<div class="nw-kpis">
|
||||
<div class="kpi"><div>Expected adds on DR</div><b>${Math.round(d.expected)}</b><small>90% range ${Math.round(d.range[0])}-${Math.round(d.range[1])}</small></div>
|
||||
<div class="kpi"><div>Likely or better</div><b>${likely}</b><small>${veryLikely} very likely (70%+)</small></div>
|
||||
<div class="kpi"><div>Track record</div><b>${showcase ? pct(showcase.obs) : '—'}</b><small>${showcase ? `happened when we said ${Math.round(showcase.lo * 100)}-${Math.round(showcase.hi * 100)}%` : 'not tested yet'}</small></div>
|
||||
<div class="kpi"><div>From our top 10</div><b>${top10.toFixed(1)}</b><small>adds expected among the ten strongest candidates</small></div>
|
||||
<div class="kpi"><div>Track record</div><b>${showcase ? (showcase.obs * 100).toFixed(1) + '%' : '—'}</b><small>${showcase ? `came true when we said ${Math.round(showcase.lo * 100)}-${Math.round(showcase.hi * 100)}% (${Math.round(showcase.n).toLocaleString('en')} forecasts)` : 'not tested yet'}</small></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nw-h">Add board: most likely per station</div>
|
||||
@@ -578,8 +587,8 @@ function renderNext() {
|
||||
<div class="nw-h">How sure are we?</div>
|
||||
<div class="track"><div class="card">${chart()}</div>
|
||||
<div class="prose note"><p>Each dot is a group of past forecasts made exactly like this one: a 1-week window, ${d.horizon + 1} weeks after the latest complete week of DR data, scored on what DR actually did (walk-forward, ${t.any_origins ? Math.round(t.any_origins) + ' forecast weeks' : 'past year'}, nothing from the future used). On the dashed line the percentages mean what they say. Bigger dots hold more forecasts.</p>
|
||||
<p>${bins.map(b => `${Math.round(b.lo * 100)}-${Math.round(b.hi * 100)}%: happened ${pct(b.obs)} of ${Math.round(b.n).toLocaleString('en')} times`).join(' · ')}</p>
|
||||
<p><b>Very likely</b> 70%+ · <b>Likely</b> 40-70% · <b>Possible</b> 20-40% · <b>Long shot</b> 10-20% · <b>Outside chance</b> under 10%. "1 in 4" means: of four artists with this chance, about one gets added. Adds of old songs (Christmas, classics) are marked <span class="tag2">Seasonal return</span> when we can tell; the forecast itself does not yet separate them.</p>
|
||||
<p>${bins.map(b => `We said ${Math.round(b.lo * 100)}-${Math.round(b.hi * 100)}% (on average ${pct1(b.pred)}): it happened ${pct1(b.obs)} of ${Math.round(b.n).toLocaleString('en')} times`).join(' · ')}. Higher bands have too few past forecasts to show yet.</p>
|
||||
<p>One week is a narrow window: an average artist on DR's books has about ${(nwBase * 100).toFixed(1)}% chance of being added in any given week, and even the strongest candidates rarely pass 1 in 10. So we grade against that: <b>Top pick</b> 25× an average artist or more · <b>Strong</b> 15-25× · <b>Contender</b> 8-15× · <b>Outside chance</b> below. "1 in 10" means: of ten artists with this chance, about one gets added that week. Adds of old songs (Christmas, classics) are marked <span class="tag2">Seasonal return</span> when we can tell; the forecast itself does not yet separate them.</p>
|
||||
${t.any_roc ? `<p>Ranking quality on the same test: an artist who got added was ranked above one who did not ${Math.round(t.any_roc * 100)}% of the time (ROC-AUC ${t.any_roc.toFixed(3)}).</p>` : ''}</div></div>`;
|
||||
document.querySelectorAll('#nw [data-f]').forEach(b => b.onclick = () => { nwFilter = b.dataset.f; renderNext(); });
|
||||
document.querySelectorAll('#nw [data-g]').forEach(b => b.onclick = () => { nwGroup = b.dataset.g; renderNext(); });
|
||||
|
||||
Reference in New Issue
Block a user