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:
@@ -0,0 +1,55 @@
|
|||||||
|
# Backtest: if the artist releases a new song, will DR add it?
|
||||||
|
|
||||||
|
Events: an artist in the panel releases something (Deezer) in week t0+1, with no other release in the 6 weeks before (so an add can't be the previous song's); target: a DR add (entering rotation after 4+ weeks out) within the 8 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. 2302 release events scored, 100 (4.3%) got an add on some DR channel.
|
||||||
|
|
||||||
|
| Model | Log-loss, any channel | PR-AUC, any channel | Log-loss, per channel | PR-AUC, per channel |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| rate by in-rotation-now | 0.1791 | 0.042 | 0.0572 | 0.011 |
|
||||||
|
| rate by last-12-weeks level | 0.1604 | 0.116 | 0.0434 | 0.123 |
|
||||||
|
| event model | 0.1587 | 0.180 | 0.0384 | 0.286 |
|
||||||
|
|
||||||
|
Skill of the event model, any channel: 0.114 (0.058 to 0.183) vs in-rotation-now, 0.011 (-0.024 to 0.059) vs last-12-weeks level.
|
||||||
|
|
||||||
|
| Any-channel feature (all events) | Coefficient |
|
||||||
|
|---|---|
|
||||||
|
| intercept | -5.518 |
|
||||||
|
| log DR plays t | +0.493 |
|
||||||
|
| log DR plays 4w | +0.865 |
|
||||||
|
| log DR plays 12w | -0.826 |
|
||||||
|
| log max DR plays 12w | +0.444 |
|
||||||
|
| in rotation anywhere now | -1.361 |
|
||||||
|
| station groups in rotation now (/5) | -0.501 |
|
||||||
|
| current run anywhere (/12) | -1.509 |
|
||||||
|
| weeks since in rotation anywhere (/12) | +0.122 |
|
||||||
|
| Track Top-40 score | -0.479 |
|
||||||
|
| Airplay Top-20 score | -0.431 |
|
||||||
|
| chart entry recency 6w | +0.327 |
|
||||||
|
| chart entry recency 26w | -0.115 |
|
||||||
|
| log Track Top-40 hits | -0.306 |
|
||||||
|
| log Airplay Top-20 hits | -0.103 |
|
||||||
|
| Danish | +0.754 |
|
||||||
|
| group | -0.006 |
|
||||||
|
| female | +0.124 |
|
||||||
|
| career years (/50) | +0.532 |
|
||||||
|
| debut unknown | +0.601 |
|
||||||
|
| Christmas in window | +0.000 |
|
||||||
|
| discography known | -0.000 |
|
||||||
|
| release recency 4w | -0.131 |
|
||||||
|
| release recency 12w | -0.869 |
|
||||||
|
| log releases last 52w | -0.172 |
|
||||||
|
| releases in the window | -0.000 |
|
||||||
|
| releases in window x not in rotation now | +1.361 |
|
||||||
|
| DR: weeks since last add 13-25 | +0.133 |
|
||||||
|
| DR: last add 26+ weeks ago | +0.694 |
|
||||||
|
| DR: no add in the panel yet | -0.625 |
|
||||||
|
| Airplay Top-20: last new song 13-25 weeks ago | +0.397 |
|
||||||
|
| Airplay Top-20: 0.5-1.25x own usual gap | -0.500 |
|
||||||
|
| Airplay Top-20: last new song 2+ years ago | -0.069 |
|
||||||
|
| log archive plays per 100 sampled hours (2012-21) | +0.316 |
|
||||||
|
| log DR lists with the artist before t (2023-) | +0.435 |
|
||||||
|
| DR list recency 26w | +0.032 |
|
||||||
|
| DR lists known before t at all | -0.016 |
|
||||||
|
| NMF Denmark in the window | +0.789 |
|
||||||
|
| NMF Denmark top 10 in the window | +0.775 |
|
||||||
|
| log NMF Denmark placements last 52w | -0.068 |
|
||||||
|
| share of releases on NMF Denmark (2 years) | -0.585 |
|
||||||
+117
-5
@@ -72,6 +72,25 @@ fn window(p: &Panel, t: usize, h: usize) -> (chrono::NaiveDate, chrono::NaiveDat
|
|||||||
(w0, w0 + chrono::Duration::weeks(W as i64))
|
(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).
|
/// 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 {
|
pub fn p_nmf(p: &Panel, a: usize, t: usize) -> f64 {
|
||||||
let end_t = p.weeks[t] + chrono::Duration::days(6);
|
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
|
/// 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
|
/// 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.)
|
/// 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 {
|
pub fn fit(p: &Panel, r: &Rot, h: usize, last_week: usize) -> AddModel { Self::fit_with(p, r, h, last_week, false) }
|
||||||
let mut m = Self::fit_raw(p, r, h, last_week);
|
|
||||||
|
/// 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);
|
let hi = last_week.saturating_sub(h + W);
|
||||||
if hi + 1 >= CAL_ORIGINS + LAGS {
|
if hi + 1 >= CAL_ORIGINS + LAGS {
|
||||||
let c0 = hi + 1 - CAL_ORIGINS;
|
let c0 = hi + 1 - CAL_ORIGINS;
|
||||||
// the inner model may only use windows that closed before the first calibration origin
|
// the inner model may only use windows that closed before the first calibration origin
|
||||||
if c0 >= LAGS - 1 + h + W + 4 {
|
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));
|
let (mut dc, mut da) = (Design::new(2), Design::new(2));
|
||||||
for t in c0..=hi {
|
for t in c0..=hi {
|
||||||
for a in 0..p.a() {
|
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);
|
let (pc, pa) = inner.predict(p, r, a, t, Scenario::ACTUAL, None);
|
||||||
for c in 0..C {
|
for c in 0..C {
|
||||||
if pc[c] < 1e-4 && !r.add_in_window(a, c, t, h) { continue; } // certain zeros carry no information
|
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
|
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 dc, mut da) = (Design::new(PC), Design::new(PA));
|
||||||
let (mut x, mut xa) = (vec![0.0; PC], vec![0.0; PA]);
|
let (mut x, mut xa) = (vec![0.0; PC], vec![0.0; PA]);
|
||||||
for t in origins(h, last_week) {
|
for t in origins(h, last_week) {
|
||||||
for a in 0..p.a() {
|
for a in 0..p.a() {
|
||||||
|
if events && !clean_release(p, a, t + 1) { continue; }
|
||||||
for c in 0..C {
|
for c in 0..C {
|
||||||
// Channels where the artist hasn't been heard for 12 weeks: keep a quarter, weighted 4.
|
// 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 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);
|
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);
|
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)?;
|
writeln!(md)?;
|
||||||
Ok(rows)
|
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)
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
//! airplay model nmf [--out docs/NMF.md] New Music Friday Denmark vs DR adds
|
//! 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 synth [--out docs/SYNTH.md] synthetic rotation lists (archive + thresholds)
|
||||||
//! airplay model ifpi the 20-year IFPI test bed -> docs/IFPI.md
|
//! 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 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]
|
//! 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)?; }
|
if let Some(out) = arg(args, "--out") { std::fs::write(out, &md)?; }
|
||||||
print!("{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") => {
|
Some("adds") => {
|
||||||
if let Some(w) = arg(args, "--without") { let _ = adds::WITHOUT.set(w.split(',').map(str::to_string).collect()); }
|
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();
|
let horizons: Vec<usize> = arg(args, "--h").unwrap_or_else(|| "0,4".into()).split(',').filter_map(|s| s.trim().parse().ok()).collect();
|
||||||
|
|||||||
+19
-13
@@ -35,7 +35,8 @@ pub fn create_tables(db: &Db) -> Result<()> {
|
|||||||
target TEXT NOT NULL, -- 'rotation' (prob, mean plays) per channel, 'any' across channels;
|
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
|
-- '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' /
|
-- 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)
|
-- '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'
|
key TEXT NOT NULL, -- '{dr artist id}:{channel}' or '{dr artist id}:any'
|
||||||
horizon INTEGER NOT NULL, -- weeks after origin_week
|
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.
|
// New adds: windows of W weeks starting h = 0..=max_h weeks after the origin.
|
||||||
let tau = thresholds(p, p.w());
|
let tau = thresholds(p, p.w());
|
||||||
let rot = Rot::new(p, &tau);
|
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 {
|
for h in 0..=max_h {
|
||||||
let m = AddModel::fit(p, &rot, h, p.w() - 1);
|
let m = AddModel::fit(p, &rot, h, p.w() - 1);
|
||||||
let start = (origin + Duration::weeks(h as i64 + 1)).to_string();
|
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)")?;
|
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() {
|
for a in 0..p.a() {
|
||||||
let id = &p.artists[a].id;
|
let id = &p.artists[a].id;
|
||||||
// If they release in the window, if they don't, and blended by their release rate.
|
// Any add in the window (current songs included): no new release, or one at the usual rate.
|
||||||
let t0 = p.w() - 1;
|
let (pc1, pa1) = m.predict(p, &rot, a, t0, Scenario::new(true, false), None);
|
||||||
// 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);
|
|
||||||
let (pc0, pa0) = m.predict(p, &rot, a, t0, Scenario::new(false, 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 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 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 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,
|
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]);
|
origin.to_string(), start, prob, none, none, none]);
|
||||||
put("add_any", "any", mix(pa1, pa0))?;
|
put("add_any", "any", mix(pa1, pa0))?;
|
||||||
put("add_any_rel", "any", pa1)?;
|
put("add_any_rel", "any", ea)?;
|
||||||
put("add_any_nmf", "any", pan)?;
|
put("add_any_nmf", "any", ean)?;
|
||||||
put("p_nmf", "any", q)?;
|
put("p_nmf", "any", q)?;
|
||||||
|
if recent { put("recent_release", "any", 1.0)?; }
|
||||||
if let Some(r) = pr { put("p_release", "any", r)?; }
|
if let Some(r) = pr { put("p_release", "any", r)?; }
|
||||||
for c in 0..C {
|
for c in 0..C {
|
||||||
put("add", CHANNELS[c], mix(pc1[c], pc0[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
@@ -32,6 +32,7 @@ struct Models {
|
|||||||
tau: [u32; C],
|
tau: [u32; C],
|
||||||
direct: Vec<Direct>, // index h - 1
|
direct: Vec<Direct>, // index h - 1
|
||||||
adds: Vec<AddModel>, // index h
|
adds: Vec<AddModel>, // index h
|
||||||
|
events: AddModel,
|
||||||
rot: Rot,
|
rot: Rot,
|
||||||
index: HashMap<String, usize>,
|
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 direct = (1..=MAX_H).map(|h| Direct::fit(&panel, h, panel.w() - 1, &tau, false)).collect();
|
||||||
let rot = Rot::new(&panel, &tau);
|
let rot = Rot::new(&panel, &tau);
|
||||||
let adds = (0..=MAX_H).map(|h| AddModel::fit(&panel, &rot, h, panel.w() - 1)).collect();
|
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();
|
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> {
|
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_rel" => { e["add_any_rel"] = r3(prob); }
|
||||||
"add_any_nmf" => { e["add_any_nmf"] = r3(prob); }
|
"add_any_nmf" => { e["add_any_nmf"] = r3(prob); }
|
||||||
"p_nmf" => { e["p_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); }
|
"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); }
|
"p_release" => { e["p_release"] = r3(prob); }
|
||||||
"now" => { e["now"][ch] = json!({"on": prob.unwrap_or(0.0) > 0.5, "plays": mean}); }
|
"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 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
|
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)?,
|
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)?)))?;
|
r.get::<_, Option<f64>>(3)?, r.get::<_, Option<f64>>(4)?, r.get::<_, Option<f64>>(5)?, r.get::<_, String>(6)?)))?;
|
||||||
let mut window = String::new();
|
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("");
|
let ch = key.split_once(':').map(|x| x.1).unwrap_or("");
|
||||||
if target == "now" { fold(&mut now, "now", ch, prob, mean, lo, hi); continue; }
|
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": {}}));
|
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);
|
fold(e, &target, ch, prob, mean, lo, hi);
|
||||||
}
|
}
|
||||||
now_out = now["now"].clone();
|
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 run = |overrides: bool| -> Value {
|
||||||
let f: Option<&dyn Fn(&mut [f64], [usize; 4])> = if overrides { Some(&over) } else { None };
|
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 x = vec![0.0; P];
|
||||||
let mut mu = [0.0; C];
|
let mut mu = [0.0; C];
|
||||||
for c in 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();
|
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!({
|
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<_>>(),
|
"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(),
|
"window_start": (p.weeks[t0] + chrono::Duration::weeks(h as i64 + 1)).to_string(),
|
||||||
"current": {"t40": chart.t40_rank, "air": chart.air_rank,
|
"current": {"t40": chart.t40_rank, "air": chart.air_rank,
|
||||||
|
|||||||
+14
-11
@@ -120,8 +120,8 @@ svg text { fill: var(--muted); font-size: 11px; }
|
|||||||
</div>
|
</div>
|
||||||
<div class="ctl">Assume
|
<div class="ctl">Assume
|
||||||
<select id="mode">
|
<select id="mode">
|
||||||
<option value="rel">They release in the window</option>
|
<option value="rel">They release a new song</option>
|
||||||
<option value="mix">Their usual release rate</option>
|
<option value="mix">Any add (current songs included)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="ctl">Sort by
|
<div class="ctl">Sort by
|
||||||
@@ -132,7 +132,8 @@ svg text { fill: var(--muted); font-size: 11px; }
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="ctl">Artist <input type="search" id="q" placeholder="Search…"></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>
|
||||||
<div class="tablewrap">
|
<div class="tablewrap">
|
||||||
<table>
|
<table>
|
||||||
@@ -145,7 +146,7 @@ svg text { fill: var(--muted); font-size: 11px; }
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<button class="more" id="more" hidden>Show more</button>
|
<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>
|
||||||
|
|
||||||
<section id="tab-model" hidden>
|
<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>
|
<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>
|
<h2>Known limits</h2>
|
||||||
<ul>
|
<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>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>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>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>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>
|
<li><b>Christmas</b> is only seen once, as history. Forecasts for weeks 48–52 don't know about Christmas songs yet.</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -247,7 +248,8 @@ async function loadRank() {
|
|||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
const h = +$('h').value, g = $('ch').value, sort = $('sort').value, q = $('q').value.trim().toLowerCase(), dk = $('dk').checked;
|
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]
|
const key = sort === 'p' ? r => [chanP(r, g) ?? 0, chanPlays(r, g) ?? 0]
|
||||||
: sort === 'plays' ? r => [chanPlays(r, g) ?? 0, 0]
|
: sort === 'plays' ? r => [chanPlays(r, g) ?? 0, 0]
|
||||||
: r => [(chanPlays(r, g) ?? 0) - nowPlays(r, g), 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>` : '';
|
const range = g === 'any' ? ` <small class="note">(${Math.round(r.lo)}–${Math.round(r.hi)})</small>` : '';
|
||||||
return `<tr data-id="${esc(r.id)}">
|
return `<tr data-id="${esc(r.id)}">
|
||||||
<td class="l">${i + 1}</td>
|
<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>
|
<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('')}
|
${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>
|
<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>
|
<button class="x" aria-label="Close" onclick="closeDrawer()">×</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="sec">
|
<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="kpis">
|
||||||
<div class="kpi"><div>Any DR station</div><b>${pct(fc.add_any)}</b></div>
|
<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('')}
|
${GROUPS.map(([g, l]) => `<div class="kpi"><div>${l}</div><b>${pct(chanP(fc, g))}</b></div>`).join('')}
|
||||||
</div>
|
</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>
|
<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>
|
||||||
<div class="sec"><h3>Weekly plays, last 51 weeks and next 12</h3>${historyChart(a)}</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';
|
$('tab-rank').hidden = b.dataset.tab !== 'rank'; $('tab-model').hidden = b.dataset.tab !== 'model';
|
||||||
}));
|
}));
|
||||||
$('h').addEventListener('input', () => { shown = 100; loadRank(); });
|
$('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(); });
|
$('q').addEventListener('input', () => { shown = 100; render(); });
|
||||||
$('more').addEventListener('click', () => { 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); });
|
$('rows').addEventListener('click', e => { const tr = e.target.closest('tr[data-id]'); if (tr) showArtist(tr.dataset.id); });
|
||||||
|
|||||||
Reference in New Issue
Block a user