Best week: colour only differences of 3+ points, say so when weeks are nearly equal

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 12:35:51 +00:00
co-authored by Claude Opus 5.5
parent 3699944692
commit 6d1f97f5bd
+5 -3
View File
@@ -480,11 +480,13 @@ async function loadBest() {
const max = Math.max(...vals), min = Math.min(...vals), avg = vals.reduce((s, v) => s + v, 0) / (vals.length || 1);
const best = b.weeks.find(x => val(x) === max);
// like a fare calendar: green = among the best weeks for this artist, red = among the worst
const level = v => { if (v == null || max === min) return 2; const z = (v - min) / (max - min); return z >= 0.85 ? 0 : z >= 0.5 ? 1 : z >= 0.2 ? 2 : 3; };
// Colour only real differences: under 3 percentage points across the calendar, the weeks are equal.
const spread = max - min;
const level = v => { if (v == null || spread < 0.03) return 2; const z = (v - min) / spread; return z >= 0.85 ? 0 : z >= 0.5 ? 1 : z >= 0.2 ? 2 : 3; };
$('bw-out').innerHTML = vals.length ? `
<div class="bw-head"><h2>${esc(b.name)}</h2>
<span>Best week: <b>${fmtDate(best.week)}</b> · <b>${pct(max)}</b> chance DR adds a new song within ${w} weeks${ch === 'any' ? '' : ' on ' + ch} (average over the calendar ${pct(avg)}).</span></div>
<div class="cal">${b.weeks.map(x => { const v = val(x); return `<div class="day ${x.too_soon ? 'soon' : 'lvl' + level(v)} ${x === best ? 'best' : ''}" title="Release the week of ${fmtDate(x.week)}">
<span>${spread < 0.03 ? `The weeks are nearly equal (within ${Math.max(1, Math.round(spread * 100))} percentage points): about <b>${pct(avg)}</b> chance DR adds a new song within ${w} weeks${ch === 'any' ? '' : ' on ' + ch}, whichever week (outside the "too soon" weeks).` : `Best week: <b>${fmtDate(best.week)}</b> · <b>${pct(max)}</b> chance DR adds a new song within ${w} weeks${ch === 'any' ? '' : ' on ' + ch} (worst ${pct(min)}, average ${pct(avg)}).`}</span></div>
<div class="cal">${b.weeks.map(x => { const v = val(x); return `<div class="day ${x.too_soon ? 'soon' : 'lvl' + level(v)} ${x === best && spread >= 0.03 ? 'best' : ''}" title="Release the week of ${fmtDate(x.week)}">
<div class="d">Week of ${fmtDate(x.week)}</div><div class="v">${x.too_soon ? 'too soon' : pct(v)}</div>${x.christmas ? '<span class="tag" title="Christmas weeks">🎄</span>' : ''}</div>`; }).join('')}</div>
<p class="note">Each tile: if ${esc(b.name)} releases a new song that week, the chance DR puts it into rotation within ${w} weeks. ${b.last_release ? `Their last release: ${fmtDate(b.last_release)}; weeks less than 6 weeks after it are "too soon" (the model only learned from releases with a clear gap).` : ''} The new song's NMF Denmark placement: ${nmf === 'auto' ? `as often as their releases were placed (${pct(b.p_nmf)})` : nmf === 'yes' ? 'placed' : 'not placed'}. What moves the numbers from week to week: time since their last release and last DR add, Christmas, and their NMF history; their current airplay is taken as it is now.</p>`
: `<h2>${esc(b.name)}</h2><p class="empty">No week in the next 26 has an estimate.</p>`;