Release-event model: 'if the artist releases a new song, will DR add it' trained on clean releases (no other release in the 6 weeks before), with its own walk-forward test; ranking defaults to it and leaves out artists who just released; pool note updated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 11:59:58 +00:00
co-authored by Claude Opus 5.5
parent e94601b997
commit 347680bc9e
6 changed files with 229 additions and 34 deletions
+117 -5
View File
@@ -72,6 +72,25 @@ fn window(p: &Panel, t: usize, h: usize) -> (chrono::NaiveDate, chrono::NaiveDat
(w0, w0 + chrono::Duration::weeks(W as i64))
}
/// Did the artist release something (Deezer discography) in DR week w (Monday to Sunday)?
pub fn released_in_week(p: &Panel, a: usize, w: usize) -> bool {
let Some(dates) = p.releases[a].as_ref() else { return false };
let start = p.weeks[0] + chrono::Duration::weeks(w as i64);
dates.iter().any(|d| *d >= start && *d < start + chrono::Duration::days(7))
}
/// A clean release event in week w: a release that week and none in the 6 weeks before it, so an
/// add that follows can't be the previous song's (DR's counts are per artist, not per song).
pub const CLEAN_WEEKS: usize = 6;
pub fn clean_release(p: &Panel, a: usize, w: usize) -> bool {
released_in_week(p, a, w) && (w.saturating_sub(CLEAN_WEEKS)..w).all(|k| !released_in_week(p, a, k))
}
/// Did the artist release something in the CLEAN_WEEKS weeks up to and including week t?
pub fn recent_release(p: &Panel, a: usize, t: usize) -> bool {
((t + 1).saturating_sub(CLEAN_WEEKS)..=t).any(|k| released_in_week(p, a, k))
}
/// P(an artist's release is placed on NMF Denmark), from the past two years (shrunk).
pub fn p_nmf(p: &Panel, a: usize, t: usize) -> f64 {
let end_t = p.weeks[t] + chrono::Duration::days(6);
@@ -280,17 +299,26 @@ impl AddModel {
/// The logits on every window closed by `last_week`, then a recalibration: an inner model fitted
/// on windows closed before the last CAL_ORIGINS origins predicts those origins, and a Platt fit
/// maps its probabilities to what happened. (The raw fits were overconfident above ~0.4.)
pub fn fit(p: &Panel, r: &Rot, h: usize, last_week: usize) -> AddModel {
let mut m = Self::fit_raw(p, r, h, last_week);
pub fn fit(p: &Panel, r: &Rot, h: usize, last_week: usize) -> AddModel { Self::fit_with(p, r, h, last_week, false) }
/// The release-event model: "if the artist releases a new song in week t+1, will DR add it
/// within 8 weeks?" Trained only on artist-weeks where the artist did release in week t+1, with
/// the artist's state the week before (earlier releases and NMF placements count as history;
/// the new song's own NMF placement is the scenario variable).
pub fn fit_events(p: &Panel, r: &Rot, last_week: usize) -> AddModel { Self::fit_with(p, r, 0, last_week, true) }
fn fit_with(p: &Panel, r: &Rot, h: usize, last_week: usize, events: bool) -> AddModel {
let mut m = Self::fit_raw(p, r, h, last_week, events);
let hi = last_week.saturating_sub(h + W);
if hi + 1 >= CAL_ORIGINS + LAGS {
let c0 = hi + 1 - CAL_ORIGINS;
// the inner model may only use windows that closed before the first calibration origin
if c0 >= LAGS - 1 + h + W + 4 {
let inner = Self::fit_raw(p, r, h, c0);
let inner = Self::fit_raw(p, r, h, c0, events);
let (mut dc, mut da) = (Design::new(2), Design::new(2));
for t in c0..=hi {
for a in 0..p.a() {
if events && !clean_release(p, a, t + 1) { continue; }
let (pc, pa) = inner.predict(p, r, a, t, Scenario::ACTUAL, None);
for c in 0..C {
if pc[c] < 1e-4 && !r.add_in_window(a, c, t, h) { continue; } // certain zeros carry no information
@@ -308,15 +336,16 @@ impl AddModel {
m
}
fn fit_raw(p: &Panel, r: &Rot, h: usize, last_week: usize) -> AddModel {
fn fit_raw(p: &Panel, r: &Rot, h: usize, last_week: usize, events: bool) -> AddModel {
let (mut dc, mut da) = (Design::new(PC), Design::new(PA));
let (mut x, mut xa) = (vec![0.0; PC], vec![0.0; PA]);
for t in origins(h, last_week) {
for a in 0..p.a() {
if events && !clean_release(p, a, t + 1) { continue; }
for c in 0..C {
// Channels where the artist hasn't been heard for 12 weeks: keep a quarter, weighted 4.
let quiet = (0..LAGS).all(|i| p.y(a, c, t - i) == 0.0);
let wgt = if quiet { if mix((a as u64) << 32 ^ (c as u64) << 20 ^ t as u64 ^ 0xadd) % 4 != 0 { continue; } 4.0 } else { 1.0 };
let wgt = if quiet && !events { if mix((a as u64) << 32 ^ (c as u64) << 20 ^ t as u64 ^ 0xadd) % 4 != 0 { continue; } 4.0 } else { 1.0 };
row_channel(p, r, a, c, t, h, Scenario::ACTUAL, &mut x);
dc.push(&x, r.add_in_window(a, c, t, h) as i32 as f64, wgt);
}
@@ -487,3 +516,86 @@ pub fn backtest(p: &Panel, tau: &[u32; C], horizons: &[usize], start: usize, md:
writeln!(md)?;
Ok(rows)
}
/// Walk-forward test of the release-event model: at each origin t0 the model sees only events
/// whose 8 weeks had closed, and scores the releases of week t0+1. The new song's NMF placement
/// isn't known in advance, so it's blended from the artist's history (as on the site).
pub fn backtest_events(p: &Panel, tau: &[u32; C], start: usize, md: &mut String) -> Result<Vec<(String, usize, String, f64)>> {
let r = Rot::new(p, tau);
let mut rows = Vec::new();
let names = ["rate by in-rotation-now", "rate by last-12-weeks level", "event model"];
let mut wk_any: Vec<[f64; 3]> = Vec::new();
let mut wk_ch: Vec<[f64; 3]> = Vec::new();
let mut pairs_any: [Vec<(f64, bool)>; 3] = Default::default();
let mut pairs_ch: [Vec<(f64, bool)>; 3] = Default::default();
let (mut n_ev, mut n_hit) = (0usize, 0usize);
let lvl = |m: f64| ((m.ln_1p() / 0.5) as usize).min(7);
let level = |a: usize, t: usize| (0..LAGS).map(|i| p.group_total(a, t - i, None)).sum::<f64>() / LAGS as f64;
for t0 in start..p.w().saturating_sub(W) {
if t0 + 1 >= p.w() { break; }
let m = AddModel::fit_events(p, &r, t0);
// baselines from the training events
let (mut by_rot, mut by_lvl) = ([[1.0f64, 2.0]; 2], [[1.0f64, 2.0]; 8]);
let (mut cr, mut cl) = ([[1.0f64, 2.0]; 2], [[1.0f64, 2.0]; 8]);
for t in origins(0, t0) {
for a in 0..p.a() {
if !clean_release(p, a, t + 1) { continue; }
let y = r.add_any_in_window(a, t, 0) as i32 as f64;
let on = r.any(a, t) as usize;
by_rot[on][0] += y; by_rot[on][1] += 1.0;
let b = lvl(level(a, t)); by_lvl[b][0] += y; by_lvl[b][1] += 1.0;
for c in 0..C {
let yc = r.add_in_window(a, c, t, 0) as i32 as f64;
let onc = r.on(a, c, t) as usize;
cr[onc][0] += yc; cr[onc][1] += 1.0;
let bc = lvl((0..LAGS).map(|i| p.y(a, c, t - i)).sum::<f64>() / LAGS as f64);
cl[bc][0] += yc; cl[bc][1] += 1.0;
}
}
}
let (mut la, mut lc) = ([0.0; 3], [0.0; 3]);
let mut any_events = false;
for a in 0..p.a() {
if !clean_release(p, a, t0 + 1) { continue; }
any_events = true;
let q = p_nmf(p, a, t0);
let (pcn, pan) = m.predict(p, &r, a, t0, Scenario::new(true, true), None);
let (pcr, par) = m.predict(p, &r, a, t0, Scenario::new(true, false), None);
let pa = q * pan + (1.0 - q) * par;
let y = r.add_any_in_window(a, t0, 0);
let on = r.any(a, t0) as usize;
let preds = [by_rot[on][0] / by_rot[on][1], by_lvl[lvl(level(a, t0))][0] / by_lvl[lvl(level(a, t0))][1], pa];
for k in 0..3 { la[k] += ll(preds[k], y); pairs_any[k].push((preds[k], y)); }
n_ev += 1; n_hit += y as usize;
for c in 0..C {
let pc = q * pcn[c] + (1.0 - q) * pcr[c];
let yc = r.add_in_window(a, c, t0, 0);
let onc = r.on(a, c, t0) as usize;
let bc = lvl((0..LAGS).map(|i| p.y(a, c, t0 - i)).sum::<f64>() / LAGS as f64);
let pr = [cr[onc][0] / cr[onc][1], cl[bc][0] / cl[bc][1], pc];
for k in 0..3 { lc[k] += ll(pr[k], yc); pairs_ch[k].push((pr[k], yc)); }
}
}
if any_events { wk_any.push(la); wk_ch.push(lc); }
eprintln!("event backtest: origin {} done", p.weeks[t0]);
}
writeln!(md, "# Backtest: if the artist releases a new song, will DR add it?\n")?;
writeln!(md, "Events: an artist in the panel releases something (Deezer) in week t0+1, with no other release in the {CLEAN_WEEKS} weeks before (so an add can't be the previous song's); target: a DR add (entering rotation after {GAP}+ weeks out) within the {W} weeks from the release week. The model knows the artist's state the week before; the new song's NMF Denmark placement is blended from the artist's history. {n_ev} release events scored, {n_hit} ({:.1}%) got an add on some DR channel.\n",
100.0 * n_hit as f64 / n_ev.max(1) as f64)?;
writeln!(md, "| Model | Log-loss, any channel | PR-AUC, any channel | Log-loss, per channel | PR-AUC, per channel |\n|---|---|---|---|---|")?;
let nch = (n_ev * C).max(1) as f64;
for k in 0..3 {
let (a, c) = (wk_any.iter().map(|w| w[k]).sum::<f64>() / n_ev.max(1) as f64, wk_ch.iter().map(|w| w[k]).sum::<f64>() / nch);
let (pa, pc) = (average_precision(pairs_any[k].clone()), average_precision(pairs_ch[k].clone()));
writeln!(md, "| {} | {a:.4} | {pa:.3} | {c:.4} | {pc:.3} |", names[k])?;
for (metric, v) in [("event_logloss_any", a), ("event_prauc_any", pa), ("event_logloss_ch", c), ("event_prauc_ch", pc)] { rows.push((names[k].to_string(), 0, metric.to_string(), v)); }
}
let col = |v: &Vec<[f64; 3]>, k: usize| v.iter().map(|w| w[k]).collect::<Vec<f64>>();
let (s1, s2) = (skill(&col(&wk_any, 2), &col(&wk_any, 0)), skill(&col(&wk_any, 2), &col(&wk_any, 1)));
rows.push(("event model".into(), 0, "event_skill_any_vs_level".into(), s2.0));
writeln!(md, "\nSkill of the event model, any channel: {:.3} ({:.3} to {:.3}) vs in-rotation-now, {:.3} ({:.3} to {:.3}) vs last-12-weeks level.\n", s1.0, s1.1, s1.2, s2.0, s2.1, s2.2)?;
let m = AddModel::fit_events(p, &r, p.w() - 1);
writeln!(md, "| Any-channel feature (all events) | Coefficient |\n|---|---|")?;
for (n, b) in ANY_NAMES.iter().chain(REL_NAMES).chain(WAVE_NAMES).chain(LONG_NAMES).chain(NMF_NAMES).zip(&m.any) { writeln!(md, "| {n} | {b:+.3} |")?; }
Ok(rows)
}
+14
View File
@@ -7,6 +7,7 @@
//! airplay model nmf [--out docs/NMF.md] New Music Friday Denmark vs DR adds
//! airplay model synth [--out docs/SYNTH.md] synthetic rotation lists (archive + thresholds)
//! airplay model ifpi the 20-year IFPI test bed -> docs/IFPI.md
//! airplay model events [--out docs/BACKTEST-EVENTS.md] backtest of the release-event model
//! airplay model adds [--h 0,4] [--out docs/BACKTEST-ADDS.md] backtest of the new-add model
//! airplay model rank [--h 4] [--max-h 12] [--top 50]
@@ -82,6 +83,19 @@ pub fn run(db: &Db, args: &[String]) -> Result<()> {
if let Some(out) = arg(args, "--out") { std::fs::write(out, &md)?; }
print!("{md}");
}
Some("events") => {
let tau = common::thresholds(&p, 26);
let mut md = String::new();
let rows = adds::backtest_events(&p, &tau, 26, &mut md)?;
rank::create_tables(db)?;
let at = chrono::Utc::now().format("%Y-%m-%dT%H:%M:%SZ").to_string();
for (m, h, metric, v) in &rows {
db.conn.execute("INSERT OR REPLACE INTO backtest_scores VALUES (?1, ?2, ?3, ?4, ?5)", rusqlite::params![at, m, *h as i64, metric, v])?;
}
let out = arg(args, "--out").unwrap_or_else(|| "docs/BACKTEST-EVENTS.md".into());
std::fs::write(&out, &md)?;
print!("{md}");
}
Some("adds") => {
if let Some(w) = arg(args, "--without") { let _ = adds::WITHOUT.set(w.split(',').map(str::to_string).collect()); }
let horizons: Vec<usize> = arg(args, "--h").unwrap_or_else(|| "0,4".into()).split(',').filter_map(|s| s.trim().parse().ok()).collect();
+19 -13
View File
@@ -35,7 +35,8 @@ pub fn create_tables(db: &Db) -> Result<()> {
target TEXT NOT NULL, -- 'rotation' (prob, mean plays) per channel, 'any' across channels;
-- 'add' / 'add_any': P(new add in the 8 weeks from target_week), blended
-- by the artist's chance of releasing ('p_release'); 'add_rel' /
-- 'add_any_rel': the same if the artist releases in the window;
-- 'add_any_rel' / 'add_rel': if the artist releases a NEW song (release-event model),
-- 'add_any_nmf': ...placed on NMF Denmark; 'recent_release': released in the last 6 weeks;
-- 'now': in rotation in the origin week (prob 1/0, mean = plays)
key TEXT NOT NULL, -- '{dr artist id}:{channel}' or '{dr artist id}:any'
horizon INTEGER NOT NULL, -- weeks after origin_week
@@ -113,6 +114,16 @@ pub fn run(db: &Db, p: &Panel, max_h: usize, show_h: usize) -> Result<Vec<Line>>
// New adds: windows of W weeks starting h = 0..=max_h weeks after the origin.
let tau = thresholds(p, p.w());
let rot = Rot::new(p, &tau);
// The release-event model ("if they release a new song, will DR add it?"), the same for every
// window start: the artist's state now, the new song's NMF placement blended from history.
let ev = AddModel::fit_events(p, &rot, p.w() - 1);
let t0 = p.w() - 1;
let event: Vec<([f64; C], f64, f64, f64, bool)> = (0..p.a()).map(|a| {
let q = super::adds::p_nmf(p, a, t0);
let (pcn, pan) = ev.predict(p, &rot, a, t0, Scenario::new(true, true), None);
let (pcr, par) = ev.predict(p, &rot, a, t0, Scenario::new(true, false), None);
(std::array::from_fn(|c| q * pcn[c] + (1.0 - q) * pcr[c]), q * pan + (1.0 - q) * par, pan, q, super::adds::recent_release(p, a, t0))
}).collect();
for h in 0..=max_h {
let m = AddModel::fit(p, &rot, h, p.w() - 1);
let start = (origin + Duration::weeks(h as i64 + 1)).to_string();
@@ -121,29 +132,24 @@ pub fn run(db: &Db, p: &Panel, max_h: usize, show_h: usize) -> Result<Vec<Line>>
let mut ins = tx.prepare("INSERT OR REPLACE INTO forecasts VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)")?;
for a in 0..p.a() {
let id = &p.artists[a].id;
// If they release in the window, if they don't, and blended by their release rate.
let t0 = p.w() - 1;
// If they release: placed on NMF Denmark or not, weighted by how often the artist's
// releases were placed; if they don't release: no NMF placement.
let q = super::adds::p_nmf(p, a, t0);
let (pcn, pan) = m.predict(p, &rot, a, t0, Scenario::new(true, true), None);
let (pcr, par) = m.predict(p, &rot, a, t0, Scenario::new(true, false), None);
// Any add in the window (current songs included): no new release, or one at the usual rate.
let (pc1, pa1) = m.predict(p, &rot, a, t0, Scenario::new(true, false), None);
let (pc0, pa0) = m.predict(p, &rot, a, t0, Scenario::new(false, false), None);
let pc1: [f64; C] = std::array::from_fn(|c| q * pcn[c] + (1.0 - q) * pcr[c]);
let pa1 = q * pan + (1.0 - q) * par;
let pr = super::adds::p_release(p, a, t0);
let mix = |p1: f64, p0: f64| match pr { Some(r) => r * p1 + (1.0 - r) * p0, None => p0 };
let (ec, ea, ean, q, recent) = event[a];
let none = Option::<f64>::None;
let mut put = |target: &str, ch: &str, prob: f64| ins.execute(params![made, VERSION, target, format!("{id}:{ch}"), h as i64,
origin.to_string(), start, prob, none, none, none]);
put("add_any", "any", mix(pa1, pa0))?;
put("add_any_rel", "any", pa1)?;
put("add_any_nmf", "any", pan)?;
put("add_any_rel", "any", ea)?;
put("add_any_nmf", "any", ean)?;
put("p_nmf", "any", q)?;
if recent { put("recent_release", "any", 1.0)?; }
if let Some(r) = pr { put("p_release", "any", r)?; }
for c in 0..C {
put("add", CHANNELS[c], mix(pc1[c], pc0[c]))?;
put("add_rel", CHANNELS[c], pc1[c])?;
put("add_rel", CHANNELS[c], ec[c])?;
}
}
}
+10 -5
View File
@@ -32,6 +32,7 @@ struct Models {
tau: [u32; C],
direct: Vec<Direct>, // index h - 1
adds: Vec<AddModel>, // index h
events: AddModel,
rot: Rot,
index: HashMap<String, usize>,
}
@@ -106,8 +107,9 @@ fn fit_models(db_path: &str, made_at: String) -> Result<Models> {
let direct = (1..=MAX_H).map(|h| Direct::fit(&panel, h, panel.w() - 1, &tau, false)).collect();
let rot = Rot::new(&panel, &tau);
let adds = (0..=MAX_H).map(|h| AddModel::fit(&panel, &rot, h, panel.w() - 1)).collect();
let events = AddModel::fit_events(&panel, &rot, panel.w() - 1);
let index = panel.artists.iter().enumerate().map(|(i, a)| (a.id.clone(), i)).collect();
Ok(Models { made_at, panel, tau, direct, adds, rot, index })
Ok(Models { made_at, panel, tau, direct, adds, events, rot, index })
}
fn query(url: &str) -> HashMap<String, String> {
@@ -189,6 +191,7 @@ fn fold(e: &mut Value, target: &str, ch: &str, prob: Option<f64>, mean: Option<f
"add_any_rel" => { e["add_any_rel"] = r3(prob); }
"add_any_nmf" => { e["add_any_nmf"] = r3(prob); }
"p_nmf" => { e["p_nmf"] = r3(prob); }
"recent_release" => { e["recent_release"] = json!(true); }
"add_rel" => { if !e["add_rel"].is_object() { e["add_rel"] = json!({}); } e["add_rel"][ch] = r3(prob); }
"p_release" => { e["p_release"] = r3(prob); }
"now" => { e["now"][ch] = json!({"on": prob.unwrap_or(0.0) > 0.5, "plays": mean}); }
@@ -236,7 +239,7 @@ fn rank(st: &State, h: usize) -> Result<Reply> {
}
let mut rows: HashMap<String, Value> = HashMap::new();
let mut st_ = c.prepare("SELECT key, target, prob, mean, lo, hi, target_week FROM forecasts WHERE made_at = ?1 AND model_version = ?2
AND ((target IN ('rotation', 'any') AND horizon = ?3) OR (target IN ('add', 'add_any', 'add_rel', 'add_any_rel', 'add_any_nmf', 'p_nmf', 'p_release') AND horizon = ?4) OR target = 'now')")?;
AND ((target IN ('rotation', 'any') AND horizon = ?3) OR (target IN ('add', 'add_any', 'add_rel', 'add_any_rel', 'add_any_nmf', 'p_nmf', 'p_release', 'recent_release') AND horizon = ?4) OR target = 'now')")?;
let it = st_.query_map(params![made, VERSION, h.max(1) as i64, h as i64], |r| Ok((r.get::<_, String>(0)?, r.get::<_, String>(1)?, r.get::<_, Option<f64>>(2)?,
r.get::<_, Option<f64>>(3)?, r.get::<_, Option<f64>>(4)?, r.get::<_, Option<f64>>(5)?, r.get::<_, String>(6)?)))?;
let mut window = String::new();
@@ -301,7 +304,7 @@ fn artist(st: &State, id: &str) -> Result<Reply> {
let ch = key.split_once(':').map(|x| x.1).unwrap_or("");
if target == "now" { fold(&mut now, "now", ch, prob, mean, lo, hi); continue; }
let e = byh.entry(h).or_insert_with(|| json!({"h": h, "p": {}, "plays": {}, "add": {}}));
if target.starts_with("add") || target.starts_with("p_") { e["window_start"] = json!(week); } else { e["week"] = json!(week); }
if target.starts_with("add") || target.starts_with("p_") || target == "recent_release" { e["window_start"] = json!(week); } else { e["week"] = json!(week); }
fold(e, &target, ch, prob, mean, lo, hi);
}
now_out = now["now"].clone();
@@ -365,7 +368,9 @@ fn whatif(st: &State, q: &HashMap<String, String>) -> Result<Reply> {
let run = |overrides: bool| -> Value {
let f: Option<&dyn Fn(&mut [f64], [usize; 4])> = if overrides { Some(&over) } else { None };
let (add_c, add_any) = am.predict(p, &m.rot, a, t0, crate::model::adds::Scenario::new(release, release && nmf), f);
// A new release: the release-event model; no release: the window model (current songs only).
let (add_c, add_any) = if release { m.events.predict(p, &m.rot, a, t0, crate::model::adds::Scenario::new(true, nmf), f) }
else { am.predict(p, &m.rot, a, t0, crate::model::adds::Scenario::new(false, false), f) };
let mut x = vec![0.0; P];
let mut mu = [0.0; C];
for c in 0..C {
@@ -387,7 +392,7 @@ fn whatif(st: &State, q: &HashMap<String, String>) -> Result<Reply> {
};
let now: serde_json::Map<String, Value> = (0..C).filter(|&c| m.rot.on(a, c, t0)).map(|c| (CHANNELS[c].to_string(), json!(p.y(a, c, t0)))).collect();
ok(json!({
"h": h, "release": release, "nmf": nmf, "p_release": crate::model::adds::p_release(p, a, t0), "p_nmf": crate::model::adds::p_nmf(p, a, t0),
"h": h, "release": release, "nmf": nmf, "p_release": crate::model::adds::p_release(p, a, t0), "p_nmf": crate::model::adds::p_nmf(p, a, t0), "recent_release": crate::model::adds::recent_release(p, a, t0),
"nmf_history": p.nmf_dk[a].iter().rev().take(8).map(|(d, pos)| json!({"friday": d.to_string(), "position": pos})).collect::<Vec<_>>(),
"window_start": (p.weeks[t0] + chrono::Duration::weeks(h as i64 + 1)).to_string(),
"current": {"t40": chart.t40_rank, "air": chart.air_rank,
+14 -11
View File
@@ -120,8 +120,8 @@ svg text { fill: var(--muted); font-size: 11px; }
</div>
<div class="ctl">Assume
<select id="mode">
<option value="rel">They release in the window</option>
<option value="mix">Their usual release rate</option>
<option value="rel">They release a new song</option>
<option value="mix">Any add (current songs included)</option>
</select>
</div>
<div class="ctl">Sort by
@@ -132,7 +132,8 @@ svg text { fill: var(--muted); font-size: 11px; }
</select>
</div>
<div class="ctl">Artist <input type="search" id="q" placeholder="Search…"></div>
<div class="ctl"><label class="chk"><input type="checkbox" id="dk"> Danish acts only</label></div>
<div class="ctl"><label class="chk"><input type="checkbox" id="dk"> Danish acts only</label>
<label class="chk" title="Artists with a release in the last 6 weeks: their current song is still running, so a new-song estimate doesn't apply yet"><input type="checkbox" id="recent"> Include artists who just released</label></div>
</div>
<div class="tablewrap">
<table>
@@ -145,7 +146,7 @@ svg text { fill: var(--muted); font-size: 11px; }
</table>
</div>
<button class="more" id="more" hidden>Show more</button>
<p class="note">"In rotation now" lists DR stations where the artist is on the list, then Bauer stations (grey) with 14+ plays in the last 7 days. "Assume they release" shows the chance if the artist releases something in the window (release dates from their Deezer discography); "usual release rate" weighs that by how often they release. <b>New add</b> = the chance that the artist gets a song into rotation within the 8-week window: entering rotation (at or above the station's weekly play threshold) after at least 4 weeks out of rotation. For "any DR station", out of rotation everywhere first. An artist with a song in rotation now usually has to drop out before a new add, which is why current hits rank lower here. "In rotation now" shows where the artist is in rotation in the latest week; plays per week are for the window's first week. Click an artist for history and a what-if.</p>
<p class="note">"In rotation now" lists DR stations where the artist is on the list, then Bauer stations (grey) with 14+ plays in the last 7 days. "They release a new song" = the chance DR adds a new song within 8 weeks of its release, learned from past releases with no other release in the 6 weeks before (so a current song's success isn't counted as the new one's); the new song's NMF Denmark placement is weighed by how often the artist's releases were placed. "Any add" = any new add in the window, current songs included. <b>New add</b> = the chance that the artist gets a song into rotation within the 8-week window: entering rotation (at or above the station's weekly play threshold) after at least 4 weeks out of rotation. For "any DR station", out of rotation everywhere first. An artist with a song in rotation now usually has to drop out before a new add, which is why current hits rank lower here. "In rotation now" shows where the artist is in rotation in the latest week; plays per week are for the window's first week. Click an artist for history and a what-if.</p>
</section>
<section id="tab-model" hidden>
@@ -164,8 +165,8 @@ svg text { fill: var(--muted); font-size: 11px; }
<p>Since streaming started counting (Nov 2014), 55% of songs on both charts hit the Track Top-40 first (median 5 weeks before airplay), 29% move together and 17% are radio first. Another 837 songs reached the Airplay Top-20 without ever charting on the Track Top-40.</p>
<h2>Known limits</h2>
<ul>
<li><b>The artist pool is selected.</b> It holds only artists DR played in mid-November 2026, so every artist had airplay at the end of the window. Scores for the last weeks are flattered.</li>
<li><b>Not yet "if they release a song on date X".</b> The ranking is expected airplay given current form and chart situation. Conditioning on a release needs release dates (being collected).</li>
<li><b>The artist pool is artists connected to DR.</b> About 7,900 artists: those DR played in mid-November 2026 (3,250) plus artists credited on tracks DR has played and their groups (4,700). Nearly half had no DR plays in the last 4 weeks, so the pool isn't only current airplay, but it isn't every releasing artist either.</li>
<li><b>Per artist, not per song.</b> DR's history counts plays per artist, so "a new song was added" is learned from releases with no other release in the 6 weeks before. For artists who just released, a new song would compete with the current one.</li>
<li><b>Rotation thresholds</b> are fitted to six of DR's weekly rotation lists inside the 51-week window ("plays ≥ threshold" matches the real lists with F1 ≈ 0.74 on P3/P4, 0.78 on P6, about 0.5 on P5/P8, which play more off-list).</li>
<li><b>Christmas</b> is only seen once, as history. Forecasts for weeks 48–52 don't know about Christmas songs yet.</li>
</ul>
@@ -247,7 +248,8 @@ async function loadRank() {
function render() {
const h = +$('h').value, g = $('ch').value, sort = $('sort').value, q = $('q').value.trim().toLowerCase(), dk = $('dk').checked;
let rows = data[h].filter(r => (!q || r.name.toLowerCase().includes(q)) && (!dk || r.danish));
const newSong = $('mode').value === 'rel';
let rows = data[h].filter(r => (!q || r.name.toLowerCase().includes(q)) && (!dk || r.danish) && (!newSong || !r.recent_release || $('recent').checked));
const key = sort === 'p' ? r => [chanP(r, g) ?? 0, chanPlays(r, g) ?? 0]
: sort === 'plays' ? r => [chanPlays(r, g) ?? 0, 0]
: r => [(chanPlays(r, g) ?? 0) - nowPlays(r, g), 0];
@@ -258,7 +260,7 @@ function render() {
const range = g === 'any' ? ` <small class="note">(${Math.round(r.lo)}–${Math.round(r.hi)})</small>` : '';
return `<tr data-id="${esc(r.id)}">
<td class="l">${i + 1}</td>
<td class="l name">${esc(r.name)}${r.danish ? '<small>DK</small>' : ''}</td>
<td class="l name">${esc(r.name)}${r.danish ? '<small>DK</small>' : ''}${r.recent_release && $('mode').value === 'rel' ? '<small title="Released in the last 6 weeks: a new song now would compete with it">just released</small>' : ''}</td>
<td><span class="bar"><i style="width:${Math.round((p ?? 0) * 70)}px"></i>${pct(p)}</span></td>
${GROUPS.map(([c]) => `<td class="hide-sm"><span class="cell" style="${heat(chanP(r, c))}">${pct(chanP(r, c))}</span></td>`).join('')}
<td class="l hide-sm">${nowChips(r.now, r.bauer)}</td>
@@ -330,12 +332,13 @@ async function showArtist(id) {
<button class="x" aria-label="Close" onclick="closeDrawer()">×</button>
</div>
<div class="sec">
<h3>Chance of a new add in the 8 weeks from ${fc.window_start ? fmtDate(fc.window_start) : '—'}${$('mode').value === 'rel' && fc.add_rel ? ', if they release in it' : ''}</h3>
<h3>${$('mode').value === 'rel' && fc.add_rel ? 'If they release a new song: chance DR adds it within 8 weeks' : `Chance of any new add in the 8 weeks from ${fc.window_start ? fmtDate(fc.window_start) : '—'} (current songs included)`}</h3>
<div class="kpis">
<div class="kpi"><div>Any DR station</div><b>${pct(fc.add_any)}</b></div>
${GROUPS.map(([g, l]) => `<div class="kpi"><div>${l}</div><b>${pct(chanP(fc, g))}</b></div>`).join('')}
</div>
${fc.p_release != null ? `<p class="note">Chance they release something in the window (from their release rate): <b>${pct(fc.p_release)}</b>. If they release: ${pct(fc.add_any_rel)} · at their usual rate: ${pct(fc.add_any)}.${fc.add_any_nmf != null ? ` If the release is placed on New Music Friday Denmark: <b>${pct(fc.add_any_nmf)}</b> (their releases were placed about ${pct(fc.p_nmf)} of the time).` : ''}</p>` : '<p class="note">No discography found on Deezer for this artist, so release timing isn\'t in the forecast.</p>'}
${fc.recent_release ? '<p class="note"><b>Just released</b> (in the last 6 weeks). DR counts plays per artist, so the model can\'t tell a new song\'s chances from the current song\'s; the new-song estimate below doesn\'t really apply until the current song has run its course, and these artists are left out of the new-song ranking by default.</p>' : ''}
${fc.p_release != null ? `<p class="note">If they release a new song: <b>${pct(fc.add_any_rel)}</b>; if it's placed on New Music Friday Denmark: <b>${pct(fc.add_any_nmf)}</b> (their releases were placed about ${pct(fc.p_nmf)} of the time). Any add in the window, current songs included: ${pct(fc.add_any)} (chance they release in the window: ${pct(fc.p_release)}).</p>` : '<p class="note">No discography found on Deezer for this artist, so release timing isn\'t in the forecast.</p>'}
<p class="note">In rotation now: ${nowChips(a.now, Object.fromEntries(Object.entries(a.bauer || {}).map(([s, v]) => [s, v.plays])))} · plays in the week of ${fp.week ? fmtDate(fp.week) : '—'}: <b>${Math.round(fp.mean ?? 0)}</b> (${Math.round(fp.lo ?? 0)}–${Math.round(fp.hi ?? 0)})</p>
</div>
<div class="sec"><h3>Weekly plays, last 51 weeks and next 12</h3>${historyChart(a)}</div>
@@ -415,7 +418,7 @@ document.querySelectorAll('nav button').forEach(b => b.addEventListener('click',
$('tab-rank').hidden = b.dataset.tab !== 'rank'; $('tab-model').hidden = b.dataset.tab !== 'model';
}));
$('h').addEventListener('input', () => { shown = 100; loadRank(); });
['ch', 'sort', 'dk', 'mode'].forEach(id => $(id).addEventListener('change', () => { shown = 100; render(); }));
['ch', 'sort', 'dk', 'mode', 'recent'].forEach(id => $(id).addEventListener('change', () => { shown = 100; render(); }));
$('q').addEventListener('input', () => { shown = 100; render(); });
$('more').addEventListener('click', () => { shown += 100; render(); });
$('rows').addEventListener('click', e => { const tr = e.target.closest('tr[data-id]'); if (tr) showArtist(tr.dataset.id); });