Rotation thresholds fitted to DR's own lists (P3 23, P4 ~14, P6 16 plays/week: ~3x the old guess); IFPI 2010-2026 walk-forward test bed and route/lead-lag analysis; site and docs updated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,142 @@
|
|||||||
|
# Backtest: new adds
|
||||||
|
|
||||||
|
An add = the artist enters rotation (plays ≥ τ) after at least 4 weeks out of rotation: per channel, and on any DR channel after 4 weeks out of rotation everywhere. Target: an add within the 8 weeks that start h weeks after the forecast origin. Origins from week 27; each fit uses only windows closed by its origin.
|
||||||
|
|
||||||
|
## Window starting h = 0 weeks ahead (17 forecast origins)
|
||||||
|
|
||||||
|
Base rates: per channel 0.75% of artist-channels get an add in the window; on any channel 4.2% of artists.
|
||||||
|
|
||||||
|
| Model | Log-loss, per channel | PR-AUC, per channel | Log-loss, any channel | PR-AUC, any channel |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| rate by in-rotation-now | 0.0440 | 0.012 | 0.1758 | 0.042 |
|
||||||
|
| rate by last-12-weeks level | 0.0328 | 0.099 | 0.1656 | 0.083 |
|
||||||
|
| logit | 0.0273 | 0.230 | 0.1563 | 0.156 |
|
||||||
|
|
||||||
|
Skill of the logit (90% block-bootstrap interval over origins):
|
||||||
|
|
||||||
|
| | vs in-rotation-now | vs last-12-weeks level |
|
||||||
|
|---|---|---|
|
||||||
|
| per channel | 0.381 (0.361 to 0.396) | 0.168 (0.148 to 0.181) |
|
||||||
|
| any channel | 0.111 (0.099 to 0.120) | 0.056 (0.040 to 0.068) |
|
||||||
|
|
||||||
|
Calibration, per channel:
|
||||||
|
|
||||||
|
| Predicted | Rows | Mean predicted | Observed |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 0.0–0.1 | 760136 | 0.003 | 0.004 |
|
||||||
|
| 0.1–0.2 | 4598 | 0.148 | 0.180 |
|
||||||
|
| 0.2–0.3 | 3797 | 0.246 | 0.219 |
|
||||||
|
| 0.3–0.4 | 1815 | 0.345 | 0.297 |
|
||||||
|
| 0.4–0.5 | 1080 | 0.444 | 0.359 |
|
||||||
|
| 0.5–0.6 | 715 | 0.548 | 0.365 |
|
||||||
|
| 0.6–0.7 | 252 | 0.643 | 0.476 |
|
||||||
|
| 0.7–0.8 | 149 | 0.742 | 0.470 |
|
||||||
|
| 0.8–0.9 | 6 | 0.809 | 0.000 |
|
||||||
|
|
||||||
|
## Window starting h = 4 weeks ahead (13 forecast origins)
|
||||||
|
|
||||||
|
Base rates: per channel 0.77% of artist-channels get an add in the window; on any channel 4.3% of artists.
|
||||||
|
|
||||||
|
| Model | Log-loss, per channel | PR-AUC, per channel | Log-loss, any channel | PR-AUC, any channel |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| rate by in-rotation-now | 0.0438 | 0.019 | 0.1752 | 0.053 |
|
||||||
|
| rate by last-12-weeks level | 0.0347 | 0.091 | 0.1689 | 0.078 |
|
||||||
|
| logit | 0.0326 | 0.139 | 0.1629 | 0.127 |
|
||||||
|
|
||||||
|
Skill of the logit (90% block-bootstrap interval over origins):
|
||||||
|
|
||||||
|
| | vs in-rotation-now | vs last-12-weeks level |
|
||||||
|
|---|---|---|
|
||||||
|
| per channel | 0.257 (0.242 to 0.276) | 0.062 (0.043 to 0.077) |
|
||||||
|
| any channel | 0.070 (0.063 to 0.075) | 0.035 (0.020 to 0.046) |
|
||||||
|
|
||||||
|
Calibration, per channel:
|
||||||
|
|
||||||
|
| Predicted | Rows | Mean predicted | Observed |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 0.0–0.1 | 579503 | 0.004 | 0.005 |
|
||||||
|
| 0.1–0.2 | 6709 | 0.143 | 0.118 |
|
||||||
|
| 0.2–0.3 | 2781 | 0.243 | 0.193 |
|
||||||
|
| 0.3–0.4 | 1213 | 0.341 | 0.232 |
|
||||||
|
| 0.4–0.5 | 375 | 0.442 | 0.291 |
|
||||||
|
| 0.5–0.6 | 131 | 0.542 | 0.198 |
|
||||||
|
| 0.6–0.7 | 42 | 0.637 | 0.571 |
|
||||||
|
| 0.7–0.8 | 18 | 0.721 | 0.667 |
|
||||||
|
|
||||||
|
## Coefficients, window starting now (h = 0), all closed windows
|
||||||
|
|
||||||
|
| Any-channel feature | Coefficient |
|
||||||
|
|---|---|
|
||||||
|
| intercept | -1.503 |
|
||||||
|
| log DR plays t | +0.669 |
|
||||||
|
| log DR plays 4w | +0.119 |
|
||||||
|
| log DR plays 12w | -0.428 |
|
||||||
|
| log max DR plays 12w | +0.140 |
|
||||||
|
| in rotation anywhere now | -2.146 |
|
||||||
|
| channels in rotation now (/14) | -2.288 |
|
||||||
|
| current run anywhere (/12) | -1.783 |
|
||||||
|
| weeks since in rotation anywhere (/12) | -2.397 |
|
||||||
|
| Track Top-40 score | +0.248 |
|
||||||
|
| Airplay Top-20 score | +0.210 |
|
||||||
|
| chart entry recency 6w | +0.482 |
|
||||||
|
| chart entry recency 26w | -0.328 |
|
||||||
|
| log Track Top-40 hits | +0.002 |
|
||||||
|
| log Airplay Top-20 hits | -0.280 |
|
||||||
|
| Danish | +0.500 |
|
||||||
|
| group | -0.468 |
|
||||||
|
| female | -0.142 |
|
||||||
|
| career years (/50) | -0.250 |
|
||||||
|
| debut unknown | +0.129 |
|
||||||
|
| Christmas in window | +0.000 |
|
||||||
|
|
||||||
|
| Per-channel feature | Coefficient |
|
||||||
|
|---|---|
|
||||||
|
| intercept | -6.792 |
|
||||||
|
| log plays t | +0.665 |
|
||||||
|
| log plays t-1 | +0.129 |
|
||||||
|
| log mean plays 4w | +0.169 |
|
||||||
|
| log mean plays 12w | -0.662 |
|
||||||
|
| log max plays 12w | +1.391 |
|
||||||
|
| log other channels t | +0.257 |
|
||||||
|
| log other channels 4w | -0.214 |
|
||||||
|
| log P3 t | +0.174 |
|
||||||
|
| weeks since played (/12) | -0.733 |
|
||||||
|
| Track Top-40 score | -0.563 |
|
||||||
|
| Airplay Top-20 score | -0.416 |
|
||||||
|
| chart entry recency 6w | +0.160 |
|
||||||
|
| chart entry recency 26w | +0.288 |
|
||||||
|
| log Track Top-40 hits | +0.260 |
|
||||||
|
| log Airplay Top-20 hits | -0.324 |
|
||||||
|
| Danish | +0.295 |
|
||||||
|
| group | -0.840 |
|
||||||
|
| female | +0.007 |
|
||||||
|
| career years (/50) | -1.415 |
|
||||||
|
| debut unknown | -0.130 |
|
||||||
|
| Christmas target week | +0.000 |
|
||||||
|
| Danish x P3 | -0.176 |
|
||||||
|
| Danish x P4 | +0.154 |
|
||||||
|
| Danish x P6 | -0.213 |
|
||||||
|
| ch p4kbh | +0.236 |
|
||||||
|
| ch p4sjaelland | +0.256 |
|
||||||
|
| ch p4fyn | +0.235 |
|
||||||
|
| ch p4syd | +0.297 |
|
||||||
|
| ch p4trekanten | +0.272 |
|
||||||
|
| ch p4vest | +0.361 |
|
||||||
|
| ch p4aarhus | +0.297 |
|
||||||
|
| ch p4nord | +0.186 |
|
||||||
|
| ch p4bornholm | +0.278 |
|
||||||
|
| ch p4esbjerg | +0.290 |
|
||||||
|
| ch p5 | +1.468 |
|
||||||
|
| ch p6beat | +0.871 |
|
||||||
|
| ch p8jazz | +1.960 |
|
||||||
|
| in rotation on channel now | -1.352 |
|
||||||
|
| in rotation anywhere now | +0.104 |
|
||||||
|
| channels in rotation now (/14) | -0.674 |
|
||||||
|
| run on channel = 1 week | +0.944 |
|
||||||
|
| run = 2 weeks | +0.352 |
|
||||||
|
| run = 3-5 weeks | -1.570 |
|
||||||
|
| run >= 6 weeks | -1.078 |
|
||||||
|
| near threshold (>= half of tau, not in rotation) | +1.389 |
|
||||||
|
| plays / tau (capped 3, /3) | -0.664 |
|
||||||
|
| weeks since in rotation on channel (/12) | +0.421 |
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Rotation thresholds from DR's lists
|
||||||
|
|
||||||
|
Lists inside the DR panel: weeks starting 2025-11-24, 2026-03-16, 2026-04-13, 2026-05-18, 2026-09-14, 2026-11-02. List lines in those weeks: 1094; artist not among the DR artists read: 167.
|
||||||
|
|
||||||
|
| Channel | τ (best F1) | F1 | Listed artist-weeks | Median plays A | B | C | Median plays, not listed but played | Old τ |
|
||||||
|
|---|---|---|---|---|---|---|---|---|
|
||||||
|
| p3 | 23 | 0.72 | 226 | 42 | 29 | 16 | 3 | 7 |
|
||||||
|
| p4kbh | 15 | 0.74 | 270 | 26 | 23 | 15 | 2 | 4 |
|
||||||
|
| p4sjaelland | 14 | 0.74 | 270 | 26 | 23 | 15 | 2 | 4 |
|
||||||
|
| p4fyn | 14 | 0.74 | 270 | 25 | 23 | 15 | 2 | 4 |
|
||||||
|
| p4syd | 14 | 0.74 | 270 | 26 | 24 | 15 | 2 | 4 |
|
||||||
|
| p4trekanten | 14 | 0.74 | 270 | 26 | 24 | 14 | 2 | 4 |
|
||||||
|
| p4vest | 13 | 0.75 | 270 | 26 | 24 | 15 | 2 | 4 |
|
||||||
|
| p4aarhus | 14 | 0.75 | 270 | 26 | 23 | 15 | 2 | 4 |
|
||||||
|
| p4nord | 15 | 0.74 | 270 | 25 | 24 | 15 | 2 | 4 |
|
||||||
|
| p4bornholm | 14 | 0.74 | 270 | 26 | 23 | 14 | 2 | 4 |
|
||||||
|
| p4esbjerg | 14 | 0.74 | 270 | 26 | 24 | 15 | 2 | 4 |
|
||||||
|
| p5 | 10 | 0.48 | 108 | 24 | 11 | 11 | 2 | 4 |
|
||||||
|
| p6beat | 16 | 0.78 | 201 | 39 | 23 | 14 | 2 | 5 |
|
||||||
|
| p8jazz | 7 | 0.53 | 250 | 14 | 9 | 6 | 2 | 3 |
|
||||||
|
|
||||||
|
The models now read these thresholds (table `rotation_thresholds`). Listed artist-weeks count an artist once per week even with several songs listed; plays are the artist's total that week, including off-list plays.
|
||||||
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# IFPI test bed
|
||||||
|
|
||||||
|
Track Top-40 from 2007-01-01, Airplay Top-20 since 2001; latest chart week 2026-10-26. Songs matched across the charts by primary artist + title without version tags.
|
||||||
|
|
||||||
|
## Routes: which chart a song reached first
|
||||||
|
|
||||||
|
Songs on both charts whose first appearance on either was after the Track Top-40 began. Lag = first Airplay Top-20 week − first Track Top-40 week.
|
||||||
|
|
||||||
|
| Period (of the first appearance) | Songs on both | Charts first (lag ≥ 2) | Same time (±1 week) | Radio first (lag ≤ −2) | Median lag, charts first | Median lag, radio first |
|
||||||
|
|---|---|---|---|---|---|---|
|
||||||
|
| 2007 (sales only) | 59 | 15% | 46% | 39% | 4 wk | 8 wk |
|
||||||
|
| Nov 2007–Oct 2014 (sales + downloads) | 532 | 43% | 43% | 13% | 6 wk | 4 wk |
|
||||||
|
| Nov 2014– (streaming counted) | 614 | 55% | 29% | 17% | 5 wk | 6 wk |
|
||||||
|
|
||||||
|
Airplay Top-20 songs never on the Track Top-40 (radio only): 2007 (sales only): 40; Nov 2007–Oct 2014 (sales + downloads): 441; Nov 2014– (streaming counted): 837.
|
||||||
|
|
||||||
|
## Walk-forward: does a Track Top-40 entry reach the Airplay Top-20 within 8 weeks?
|
||||||
|
|
||||||
|
Candidates: songs entering the Track Top-40 that hadn't been on the Airplay Top-20. Each year is scored with models fitted on the years before it.
|
||||||
|
|
||||||
|
| Year | Entries | Reached airplay | Log-loss base rate | Log-loss entry position | Log-loss full | Skill full vs base | Skill full vs position |
|
||||||
|
|---|---|---|---|---|---|---|---|
|
||||||
|
| 2010 | 202 | 29% | 0.615 | 0.599 | 0.540 | +0.121 | +0.097 |
|
||||||
|
| 2011 | 245 | 25% | 0.566 | 0.566 | 0.573 | -0.012 | -0.011 |
|
||||||
|
| 2012 | 239 | 14% | 0.440 | 0.441 | 0.358 | +0.186 | +0.188 |
|
||||||
|
| 2013 | 226 | 21% | 0.513 | 0.497 | 0.459 | +0.105 | +0.077 |
|
||||||
|
| 2014 | 250 | 30% | 0.620 | 0.587 | 0.598 | +0.035 | -0.020 |
|
||||||
|
| 2015 | 136 | 32% | 0.650 | 0.617 | 0.696 | -0.070 | -0.128 |
|
||||||
|
| 2016 | 147 | 31% | 0.634 | 0.624 | 0.578 | +0.088 | +0.073 |
|
||||||
|
| 2017 | 209 | 22% | 0.534 | 0.514 | 0.469 | +0.122 | +0.088 |
|
||||||
|
| 2018 | 257 | 14% | 0.439 | 0.454 | 0.441 | -0.004 | +0.029 |
|
||||||
|
| 2019 | 267 | 16% | 0.453 | 0.452 | 0.374 | +0.175 | +0.173 |
|
||||||
|
| 2020 | 215 | 11% | 0.394 | 0.393 | 0.260 | +0.340 | +0.338 |
|
||||||
|
| 2021 | 220 | 13% | 0.414 | 0.402 | 0.298 | +0.280 | +0.258 |
|
||||||
|
| 2022 | 204 | 19% | 0.489 | 0.473 | 0.427 | +0.128 | +0.097 |
|
||||||
|
| 2023 | 195 | 13% | 0.413 | 0.424 | 0.324 | +0.214 | +0.236 |
|
||||||
|
| 2024 | 211 | 12% | 0.397 | 0.404 | 0.331 | +0.166 | +0.180 |
|
||||||
|
| 2025 | 204 | 9% | 0.347 | 0.357 | 0.239 | +0.309 | +0.329 |
|
||||||
|
| 2026 | 157 | 15% | 0.434 | 0.431 | 0.345 | +0.206 | +0.201 |
|
||||||
|
|
||||||
|
All years: skill of the full model +0.127 vs base rate, +0.115 vs entry position only. PR-AUC: base 0.200, position 0.271, full 0.411.
|
||||||
|
|
||||||
|
| Feature (all years) | Coefficient |
|
||||||
|
|---|---|
|
||||||
|
| intercept | -2.463 |
|
||||||
|
| entry position score | +0.215 |
|
||||||
|
| entry score² | +1.482 |
|
||||||
|
| log earlier Airplay Top-20 songs | +1.097 |
|
||||||
|
| log earlier Track Top-40 songs | -0.793 |
|
||||||
|
| artist's earlier conversion rate | +1.391 |
|
||||||
|
| log Airplay Top-20 songs in the last year | +0.409 |
|
||||||
|
| entered in weeks 46–52 | +0.035 |
|
||||||
|
| streaming era | +0.160 |
|
||||||
|
| streaming × entry score | -0.422 |
|
||||||
|
|
||||||
@@ -82,3 +82,10 @@ airplay model rank [--h 4] [--max-h 12] [--top 50] the ranking for h = 1..12 -
|
|||||||
- **Not conditioned on a release yet.** The ranking is expected airplay given current form. The release-effect event study needs release dates (Deezer backfill).
|
- **Not conditioned on a release yet.** The ranking is expected airplay given current form. The release-effect event study needs release dates (Deezer backfill).
|
||||||
- **"Release timing only" is not scored yet.** That baseline needs release dates too.
|
- **"Release timing only" is not scored yet.** That baseline needs release dates too.
|
||||||
- **Christmas is barely seen.** It appears only as lag history (weeks 48–52 of 2025), never as a target week.
|
- **Christmas is barely seen.** It appears only as lag history (weeks 48–52 of 2025), never as a target week.
|
||||||
|
|
||||||
|
## Update 15 Nov 2026: new adds, rotation lists, IFPI test bed
|
||||||
|
|
||||||
|
- **New adds** (`airplay model adds`, docs/BACKTEST-ADDS.md). The ranking used to show P(artist at or above the play threshold), which is close to 100% for anyone with a current hit. It now shows the chance of a **new add**: entering rotation after at least 4 weeks out, per channel, and on any DR channel after 4 weeks out everywhere, within an 8-week window starting h = 0–12 weeks ahead. Artist-level counts can't tell a new song from an old one returning. But in a week of song-level plays only 3–12% of artists in rotation had two songs in rotation at once, so "drop out, then get added" is the usual pattern. Features include run length on the list and how close the artist is to the threshold.
|
||||||
|
- **Rotation lists** (`airplay rotations [--wayback] [--reparse]`, src/rotations.rs). Parses DR's PDF from glyph positions, with category headers, columns and the P3 summary page; decoration (rotated text) is dropped. Each page's channel comes from where its artists are played. Old lists came from the Wayback Machine's copies of DR's rotation page, giving **29 weekly lists from May 2023 to Nov 2026** in `rotation_lists`.
|
||||||
|
- **Thresholds from the lists** (`airplay model calibrate`, docs/CALIBRATION.md). The six lists inside the DR window put "in rotation" at P3 23, P4 13–15, P5 10, P6 16 and P8 7 plays a week, about three times the old play-distribution guess. Every model now uses these.
|
||||||
|
- **IFPI test bed** (`airplay model ifpi`, docs/IFPI.md): routes and lead–lag per chart period, and a 2010–2026 walk-forward test of Track Top-40 entry → Airplay Top-20 within 8 weeks.
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
//! Rotation thresholds from the real lists. For every parsed rotation list whose week lies in
|
||||||
|
//! the DR panel, compare the artists on the list (per channel; the national P4 list against each
|
||||||
|
//! regional P4) with the artists' plays that week. Reports plays by category and the threshold
|
||||||
|
//! that best separates listed from not-listed artists, and stores the thresholds in
|
||||||
|
//! `rotation_thresholds`, which the models then use instead of the play-distribution guess.
|
||||||
|
|
||||||
|
use super::panel::{key, Panel, C, CHANNELS};
|
||||||
|
use crate::db::Db;
|
||||||
|
use anyhow::Result;
|
||||||
|
use chrono::{Duration, NaiveDate};
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use std::fmt::Write as _;
|
||||||
|
|
||||||
|
pub fn create_tables(db: &Db) -> Result<()> {
|
||||||
|
db.conn.execute_batch(
|
||||||
|
"CREATE TABLE IF NOT EXISTS rotation_thresholds (
|
||||||
|
channel TEXT PRIMARY KEY, tau INTEGER NOT NULL, f1 REAL, listed INTEGER, weeks INTEGER, made_at TEXT NOT NULL
|
||||||
|
);",
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Thresholds stored by `run`, if any.
|
||||||
|
pub fn stored(db: &Db) -> Result<Option<[u32; C]>> {
|
||||||
|
create_tables(db)?;
|
||||||
|
let mut tau = [0u32; C];
|
||||||
|
let mut n = 0;
|
||||||
|
for r in db.conn.prepare("SELECT channel, tau FROM rotation_thresholds")?.query_map([], |r| Ok((r.get::<_, String>(0)?, r.get::<_, i64>(1)?)))? {
|
||||||
|
let (ch, t) = r?;
|
||||||
|
if let Some(c) = CHANNELS.iter().position(|x| *x == ch) { tau[c] = t as u32; n += 1; }
|
||||||
|
}
|
||||||
|
Ok(if n == C { Some(tau) } else { None })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The artists credited in a list line ("A [+] B", "A feat. B", "A & B", "A, B").
|
||||||
|
fn names(s: &str) -> Vec<String> {
|
||||||
|
let mut parts = vec![s.to_lowercase()];
|
||||||
|
for sep in [" [+] ", " feat. ", " feat ", " ft. ", " ft ", " featuring ", " & ", ", ", " x ", " og ", " med ", " vs. ", " vs "] {
|
||||||
|
parts = parts.iter().flat_map(|p| p.split(sep).map(str::to_string).collect::<Vec<_>>()).collect();
|
||||||
|
}
|
||||||
|
let mut out = vec![key(s)];
|
||||||
|
out.extend(parts.iter().map(|p| key(p)));
|
||||||
|
out.retain(|k| !k.is_empty());
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(db: &Db, p: &Panel) -> Result<String> {
|
||||||
|
create_tables(db)?;
|
||||||
|
let mut by_key: HashMap<String, Vec<usize>> = HashMap::new();
|
||||||
|
for (i, a) in p.artists.iter().enumerate() { by_key.entry(key(&a.name)).or_default().push(i); }
|
||||||
|
let week_of: HashMap<NaiveDate, usize> = p.weeks.iter().enumerate().map(|(i, d)| (*d, i)).collect();
|
||||||
|
|
||||||
|
// (list channel, week index) -> artist -> best category
|
||||||
|
let mut listed: HashMap<(String, usize), HashMap<usize, String>> = HashMap::new();
|
||||||
|
let mut unmatched = 0usize;
|
||||||
|
let mut total = 0usize;
|
||||||
|
let rank = |c: &str| match c { "A" => 0, "B" => 1, "C" => 2, _ => 3 };
|
||||||
|
for r in db.conn.prepare("SELECT list_date, channel, category, artist FROM rotation_lists")?
|
||||||
|
.query_map([], |r| Ok((r.get::<_, String>(0)?, r.get::<_, String>(1)?, r.get::<_, String>(2)?, r.get::<_, String>(3)?)))? {
|
||||||
|
let (date, ch, cat, artist) = r?;
|
||||||
|
let Ok(d) = NaiveDate::parse_from_str(&date, "%Y-%m-%d") else { continue };
|
||||||
|
// A Friday list applies to the week starting the following Monday.
|
||||||
|
let Some(&w) = week_of.get(&(d + Duration::days(3))) else { continue };
|
||||||
|
total += 1;
|
||||||
|
let ids: HashSet<usize> = names(&artist).iter().filter_map(|k| by_key.get(k)).flatten().copied().collect();
|
||||||
|
if ids.is_empty() { unmatched += 1; continue; }
|
||||||
|
let m = listed.entry((ch, w)).or_default();
|
||||||
|
for a in ids {
|
||||||
|
let e = m.entry(a).or_insert_with(|| cat.clone());
|
||||||
|
if rank(&cat) < rank(e) { *e = cat.clone(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut md = String::new();
|
||||||
|
writeln!(md, "# Rotation thresholds from DR's lists\n")?;
|
||||||
|
let weeks: HashSet<usize> = listed.keys().map(|k| k.1).collect();
|
||||||
|
let mut wl: Vec<String> = weeks.iter().map(|w| p.weeks[*w].to_string()).collect();
|
||||||
|
wl.sort();
|
||||||
|
writeln!(md, "Lists inside the DR panel: weeks starting {}. List lines in those weeks: {total}; artist not among the DR artists read: {unmatched}.\n", wl.join(", "))?;
|
||||||
|
writeln!(md, "| Channel | τ (best F1) | F1 | Listed artist-weeks | Median plays A | B | C | Median plays, not listed but played | Old τ |\n|---|---|---|---|---|---|---|---|---|")?;
|
||||||
|
let old = super::common::thresholds_from_plays(p, p.w());
|
||||||
|
let made = chrono::Utc::now().to_rfc3339();
|
||||||
|
let mut out_tau = [0u32; C];
|
||||||
|
for c in 0..C {
|
||||||
|
let list_ch = if CHANNELS[c].starts_with("p4") { "p4" } else { CHANNELS[c] };
|
||||||
|
let mut by_cat: HashMap<String, Vec<f64>> = HashMap::new();
|
||||||
|
let mut not_listed: Vec<f64> = Vec::new();
|
||||||
|
let mut pairs: Vec<(f64, bool)> = Vec::new();
|
||||||
|
let mut n_weeks = 0;
|
||||||
|
for &w in &weeks {
|
||||||
|
let Some(m) = listed.get(&(list_ch.to_string(), w)) else { continue };
|
||||||
|
n_weeks += 1;
|
||||||
|
for a in 0..p.a() {
|
||||||
|
let y = p.y(a, c, w);
|
||||||
|
match m.get(&a) {
|
||||||
|
Some(cat) => { by_cat.entry(cat.clone()).or_default().push(y); pairs.push((y, true)); }
|
||||||
|
None => { if y > 0.0 { not_listed.push(y); } pairs.push((y, false)); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if n_weeks == 0 { out_tau[c] = old[c]; continue; }
|
||||||
|
let med = |v: Option<&Vec<f64>>| v.filter(|v| !v.is_empty()).map(|v| { let mut v = v.clone(); v.sort_by(f64::total_cmp); v[v.len() / 2] }).map(|m| format!("{m:.0}")).unwrap_or("—".into());
|
||||||
|
// Best threshold by F1 of "plays >= tau" against "on the list".
|
||||||
|
let (mut best, mut best_f1) = (old[c], 0.0);
|
||||||
|
for tau in 1..=40u32 {
|
||||||
|
let (mut tp, mut fp, mut fn_) = (0.0, 0.0, 0.0);
|
||||||
|
for (y, l) in &pairs {
|
||||||
|
let pred = *y >= tau as f64;
|
||||||
|
match (pred, *l) { (true, true) => tp += 1.0, (true, false) => fp += 1.0, (false, true) => fn_ += 1.0, _ => {} }
|
||||||
|
}
|
||||||
|
let f1 = if tp > 0.0 { 2.0 * tp / (2.0 * tp + fp + fn_) } else { 0.0 };
|
||||||
|
if f1 > best_f1 { best_f1 = f1; best = tau; }
|
||||||
|
}
|
||||||
|
out_tau[c] = best;
|
||||||
|
let n_listed = pairs.iter().filter(|x| x.1).count();
|
||||||
|
let mut nl = not_listed.clone();
|
||||||
|
nl.sort_by(f64::total_cmp);
|
||||||
|
writeln!(md, "| {} | {best} | {best_f1:.2} | {n_listed} | {} | {} | {} | {} | {} |", CHANNELS[c], med(by_cat.get("A")), med(by_cat.get("B")), med(by_cat.get("C")),
|
||||||
|
med(Some(&nl)), old[c])?;
|
||||||
|
db.conn.execute("INSERT OR REPLACE INTO rotation_thresholds VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
|
||||||
|
rusqlite::params![CHANNELS[c], best as i64, best_f1, n_listed as i64, n_weeks as i64, made])?;
|
||||||
|
}
|
||||||
|
writeln!(md, "\nThe models now read these thresholds (table `rotation_thresholds`). Listed artist-weeks count an artist once per week even with several songs listed; plays are the artist's total that week, including off-list plays.\n")?;
|
||||||
|
Ok(md)
|
||||||
|
}
|
||||||
+9
-3
@@ -5,10 +5,16 @@ use super::features::{self, LAGS, P};
|
|||||||
use super::glm::{self, Design};
|
use super::glm::{self, Design};
|
||||||
use super::panel::{Panel, C};
|
use super::panel::{Panel, C};
|
||||||
|
|
||||||
/// "In rotation" on channel c = at least tau[c] plays in the week. Set from each channel's
|
/// "In rotation" on channel c = at least tau[c] plays in the week: the thresholds fitted to DR's
|
||||||
/// distribution of non-zero artist-weeks (75th percentile, at least 3) over weeks < `upto`;
|
/// rotation lists if `airplay model calibrate` has run, else each channel's 75th percentile of
|
||||||
/// to be calibrated on the Friday rotation lists once they're parsed.
|
/// non-zero artist-weeks (at least 3) over weeks < `upto`.
|
||||||
pub fn thresholds(p: &Panel, upto: usize) -> [u32; C] {
|
pub fn thresholds(p: &Panel, upto: usize) -> [u32; C] {
|
||||||
|
// Calibrated on DR's own rotation lists when available (`airplay model calibrate`).
|
||||||
|
if let Some(t) = p.list_tau { return t; }
|
||||||
|
thresholds_from_plays(p, upto)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn thresholds_from_plays(p: &Panel, upto: usize) -> [u32; C] {
|
||||||
let mut tau = [3u32; C];
|
let mut tau = [3u32; C];
|
||||||
for (c, t) in tau.iter_mut().enumerate() {
|
for (c, t) in tau.iter_mut().enumerate() {
|
||||||
let mut v: Vec<f64> = (0..p.a()).flat_map(|a| (0..upto).map(move |w| (a, w))).map(|(a, w)| p.y(a, c, w)).filter(|&y| y > 0.0).collect();
|
let mut v: Vec<f64> = (0..p.a()).flat_map(|a| (0..upto).map(move |w| (a, w))).map(|(a, w)| p.y(a, c, w)).filter(|&y| y > 0.0).collect();
|
||||||
|
|||||||
@@ -0,0 +1,175 @@
|
|||||||
|
//! The IFPI test bed (doc: "Two backtest beds"): 20 years of national, song-level charts.
|
||||||
|
//!
|
||||||
|
//! Track Top-40 (sales + streaming, streaming counted from Nov 2014) since 2007
|
||||||
|
//! Airplay Top-20 (most played on the big Danish stations) since 2001-W38
|
||||||
|
//!
|
||||||
|
//! 1. Routes and lead–lag: for songs on both charts, which came first and by how many weeks,
|
||||||
|
//! per chart period.
|
||||||
|
//! 2. A walk-forward test: when a song enters the Track Top-40 without having been on the
|
||||||
|
//! Airplay Top-20, does it reach the Airplay Top-20 within 8 weeks? Fitted on years before
|
||||||
|
//! Y, scored on year Y, for Y = 2010..now, against a base rate and an entry-position-only model.
|
||||||
|
//!
|
||||||
|
//! airplay model ifpi -> docs/IFPI.md
|
||||||
|
|
||||||
|
use super::glm::{self, Design};
|
||||||
|
use super::panel::key;
|
||||||
|
use crate::db::Db;
|
||||||
|
use anyhow::Result;
|
||||||
|
use chrono::{Datelike, NaiveDate, Weekday};
|
||||||
|
use std::collections::{BTreeMap, HashMap};
|
||||||
|
use std::fmt::Write as _;
|
||||||
|
|
||||||
|
const WINDOW: i64 = 8;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct Row { chart_t40: bool, monday: NaiveDate, pos: i64, song: String, primary: String }
|
||||||
|
|
||||||
|
/// The song's key: primary artist + title without version tags.
|
||||||
|
fn song_key(artist: &str, title: &str) -> (String, String) {
|
||||||
|
let lower = artist.to_lowercase();
|
||||||
|
let mut cut = lower.len();
|
||||||
|
for sep in [" feat.", " feat ", " ft.", " ft ", " featuring ", " & ", ", ", " x ", " og ", " med ", " vs", " / ", " + "] {
|
||||||
|
if let Some(i) = lower.find(sep) { cut = cut.min(i); }
|
||||||
|
}
|
||||||
|
let primary = key(&lower[..cut]);
|
||||||
|
let t = title.split(" (").next().unwrap_or(title).split(" - ").next().unwrap_or(title);
|
||||||
|
(primary.clone(), format!("{primary}|{}", key(t)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn period(d: NaiveDate) -> &'static str {
|
||||||
|
if d < NaiveDate::from_ymd_opt(2007, 11, 1).unwrap() { "2007 (sales only)" }
|
||||||
|
else if d < NaiveDate::from_ymd_opt(2014, 11, 1).unwrap() { "Nov 2007–Oct 2014 (sales + downloads)" }
|
||||||
|
else { "Nov 2014– (streaming counted)" }
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Song { first_t40: Option<(NaiveDate, i64)>, first_air: Option<NaiveDate>, primary: String }
|
||||||
|
|
||||||
|
pub fn run(db: &Db) -> Result<String> {
|
||||||
|
let mut rows = Vec::new();
|
||||||
|
for r in db.conn.prepare("SELECT chart, year, week, position, artist, title FROM hitlisten_charts WHERE chart IN ('t40', 'airplay')")?
|
||||||
|
.query_map([], |r| Ok((r.get::<_, String>(0)?, r.get::<_, i32>(1)?, r.get::<_, u32>(2)?, r.get::<_, i64>(3)?, r.get::<_, String>(4)?, r.get::<_, String>(5)?)))? {
|
||||||
|
let (chart, y, w, pos, artist, title) = r?;
|
||||||
|
let Some(monday) = NaiveDate::from_isoywd_opt(y, w, Weekday::Mon) else { continue };
|
||||||
|
let (primary, song) = song_key(&artist, &title);
|
||||||
|
rows.push(Row { chart_t40: chart == "t40", monday, pos, song, primary });
|
||||||
|
}
|
||||||
|
rows.sort_by_key(|r| r.monday);
|
||||||
|
let t40_start = rows.iter().filter(|r| r.chart_t40).map(|r| r.monday).min().unwrap_or_default();
|
||||||
|
let last_week = rows.iter().map(|r| r.monday).max().unwrap_or_default();
|
||||||
|
|
||||||
|
let mut songs: HashMap<String, Song> = HashMap::new();
|
||||||
|
for r in &rows {
|
||||||
|
let s = songs.entry(r.song.clone()).or_insert(Song { first_t40: None, first_air: None, primary: r.primary.clone() });
|
||||||
|
if r.chart_t40 { if s.first_t40.is_none() { s.first_t40 = Some((r.monday, r.pos)); } }
|
||||||
|
else if s.first_air.is_none() { s.first_air = Some(r.monday); }
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut md = String::new();
|
||||||
|
writeln!(md, "# IFPI test bed\n")?;
|
||||||
|
writeln!(md, "Track Top-40 from {t40_start}, Airplay Top-20 since 2001; latest chart week {last_week}. Songs matched across the charts by primary artist + title without version tags.\n")?;
|
||||||
|
|
||||||
|
// ---- 1. routes and lead–lag
|
||||||
|
writeln!(md, "## Routes: which chart a song reached first\n")?;
|
||||||
|
writeln!(md, "Songs on both charts whose first appearance on either was after the Track Top-40 began. Lag = first Airplay Top-20 week − first Track Top-40 week.\n")?;
|
||||||
|
writeln!(md, "| Period (of the first appearance) | Songs on both | Charts first (lag ≥ 2) | Same time (±1 week) | Radio first (lag ≤ −2) | Median lag, charts first | Median lag, radio first |\n|---|---|---|---|---|---|---|")?;
|
||||||
|
let mut by_period: BTreeMap<&str, Vec<i64>> = BTreeMap::new();
|
||||||
|
let mut only_air: BTreeMap<&str, usize> = BTreeMap::new();
|
||||||
|
for s in songs.values() {
|
||||||
|
match (s.first_t40, s.first_air) {
|
||||||
|
(Some((t, _)), Some(a)) if t.min(a) > t40_start + chrono::Duration::weeks(4) => {
|
||||||
|
by_period.entry(period(t.min(a))).or_default().push((a - t).num_weeks());
|
||||||
|
}
|
||||||
|
(None, Some(a)) if a > t40_start + chrono::Duration::weeks(4) => *only_air.entry(period(a)).or_insert(0) += 1,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let median = |mut v: Vec<i64>| -> String { if v.is_empty() { return "—".into(); } v.sort(); format!("{}", v[v.len() / 2]) };
|
||||||
|
for (p, lags) in &by_period {
|
||||||
|
let n = lags.len() as f64;
|
||||||
|
let cf: Vec<i64> = lags.iter().copied().filter(|l| *l >= 2).collect();
|
||||||
|
let rf: Vec<i64> = lags.iter().copied().filter(|l| *l <= -2).map(|l| -l).collect();
|
||||||
|
let same = lags.iter().filter(|l| l.abs() <= 1).count() as f64;
|
||||||
|
writeln!(md, "| {p} | {} | {:.0}% | {:.0}% | {:.0}% | {} wk | {} wk |", lags.len(), 100.0 * cf.len() as f64 / n, 100.0 * same / n, 100.0 * rf.len() as f64 / n, median(cf), median(rf))?;
|
||||||
|
}
|
||||||
|
writeln!(md, "\nAirplay Top-20 songs never on the Track Top-40 (radio only): {}.\n",
|
||||||
|
only_air.iter().map(|(p, n)| format!("{p}: {n}")).collect::<Vec<_>>().join("; "))?;
|
||||||
|
|
||||||
|
// ---- 2. walk-forward: Track Top-40 entry -> Airplay Top-20 within 8 weeks
|
||||||
|
// Artist history as of a date: earlier Airplay Top-20 songs and Track Top-40 songs.
|
||||||
|
let mut air_songs_by_artist: HashMap<String, Vec<NaiveDate>> = HashMap::new();
|
||||||
|
let mut t40_songs_by_artist: HashMap<String, Vec<(NaiveDate, bool)>> = HashMap::new(); // entry date, reached airplay
|
||||||
|
for s in songs.values() {
|
||||||
|
if let Some(a) = s.first_air { air_songs_by_artist.entry(s.primary.clone()).or_default().push(a); }
|
||||||
|
if let Some((t, _)) = s.first_t40 {
|
||||||
|
let reached = s.first_air.is_some_and(|a| a >= t && (a - t).num_weeks() <= WINDOW);
|
||||||
|
t40_songs_by_artist.entry(s.primary.clone()).or_default().push((t, reached));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
struct Ex { date: NaiveDate, x: Vec<f64>, y: bool }
|
||||||
|
let mut ex: Vec<Ex> = Vec::new();
|
||||||
|
for s in songs.values() {
|
||||||
|
let Some((t, pos)) = s.first_t40 else { continue };
|
||||||
|
if t <= t40_start + chrono::Duration::weeks(4) { continue; } // already charting when the chart began
|
||||||
|
if t + chrono::Duration::weeks(WINDOW) > last_week { continue; } // window not closed
|
||||||
|
if s.first_air.is_some_and(|a| a < t) { continue; } // radio got there first: not a candidate
|
||||||
|
let y = s.first_air.is_some_and(|a| (a - t).num_weeks() <= WINDOW);
|
||||||
|
let prior_air = air_songs_by_artist.get(&s.primary).map(|v| v.iter().filter(|d| **d < t).count()).unwrap_or(0) as f64;
|
||||||
|
let prior: Vec<&(NaiveDate, bool)> = t40_songs_by_artist.get(&s.primary).map(|v| v.iter().filter(|(d, _)| *d + chrono::Duration::weeks(WINDOW) <= t).collect()).unwrap_or_default();
|
||||||
|
let prior_t40 = prior.len() as f64;
|
||||||
|
// the artist's earlier conversion rate (shrunk towards the overall ~ rate)
|
||||||
|
let conv = (prior.iter().filter(|p| p.1).count() as f64 + 0.3) / (prior_t40 + 1.0);
|
||||||
|
let recent_air = air_songs_by_artist.get(&s.primary).map(|v| v.iter().filter(|d| **d < t && (t - **d).num_weeks() <= 52).count()).unwrap_or(0) as f64;
|
||||||
|
let wk = t.iso_week().week();
|
||||||
|
let streaming = (t >= NaiveDate::from_ymd_opt(2014, 11, 1).unwrap()) as i32 as f64;
|
||||||
|
let x = vec![1.0, (41.0 - pos as f64) / 40.0, ((41.0 - pos as f64) / 40.0).powi(2), prior_air.ln_1p(), prior_t40.ln_1p(), conv,
|
||||||
|
recent_air.ln_1p(), (wk >= 46) as i32 as f64, streaming, streaming * (41.0 - pos as f64) / 40.0];
|
||||||
|
ex.push(Ex { date: t, x, y });
|
||||||
|
}
|
||||||
|
ex.sort_by_key(|e| e.date);
|
||||||
|
let names = ["intercept", "entry position score", "entry score²", "log earlier Airplay Top-20 songs", "log earlier Track Top-40 songs",
|
||||||
|
"artist's earlier conversion rate", "log Airplay Top-20 songs in the last year", "entered in weeks 46–52", "streaming era", "streaming × entry score"];
|
||||||
|
let ll = |p: f64, y: bool| -(if y { p } else { 1.0 - p }).clamp(1e-9, 1.0).ln();
|
||||||
|
writeln!(md, "## Walk-forward: does a Track Top-40 entry reach the Airplay Top-20 within {WINDOW} weeks?\n")?;
|
||||||
|
writeln!(md, "Candidates: songs entering the Track Top-40 that hadn't been on the Airplay Top-20. Each year is scored with models fitted on the years before it.\n")?;
|
||||||
|
writeln!(md, "| Year | Entries | Reached airplay | Log-loss base rate | Log-loss entry position | Log-loss full | Skill full vs base | Skill full vs position |\n|---|---|---|---|---|---|---|---|")?;
|
||||||
|
let first_year = ex.first().map(|e| e.date.year()).unwrap_or(2010).max(2010);
|
||||||
|
let last_year = ex.last().map(|e| e.date.year()).unwrap_or(2026);
|
||||||
|
let (mut tot_b, mut tot_p, mut tot_f) = (0.0, 0.0, 0.0);
|
||||||
|
let mut pairs: [Vec<(f64, bool)>; 3] = Default::default();
|
||||||
|
for year in first_year..=last_year {
|
||||||
|
let train: Vec<&Ex> = ex.iter().filter(|e| e.date.year() < year && e.date + chrono::Duration::weeks(WINDOW) < NaiveDate::from_ymd_opt(year, 1, 1).unwrap()).collect();
|
||||||
|
let test: Vec<&Ex> = ex.iter().filter(|e| e.date.year() == year).collect();
|
||||||
|
if train.len() < 200 || test.is_empty() { continue; }
|
||||||
|
let rate = (train.iter().filter(|e| e.y).count() as f64 + 1.0) / (train.len() as f64 + 2.0);
|
||||||
|
let fit = |cols: &[usize]| {
|
||||||
|
let mut d = Design::new(cols.len());
|
||||||
|
for e in &train { let x: Vec<f64> = cols.iter().map(|&c| e.x[c]).collect(); d.push(&x, e.y as i32 as f64, 1.0); }
|
||||||
|
glm::logit(&d, 1.0)
|
||||||
|
};
|
||||||
|
let pos_cols = [0usize, 1, 2];
|
||||||
|
let all: Vec<usize> = (0..names.len()).collect();
|
||||||
|
let (bp, bf) = (fit(&pos_cols), fit(&all));
|
||||||
|
let pr = |b: &[f64], cols: &[usize], e: &Ex| glm::sigmoid(cols.iter().zip(b).map(|(&c, w)| e.x[c] * w).sum::<f64>());
|
||||||
|
let (mut lb, mut lp, mut lf) = (0.0, 0.0, 0.0);
|
||||||
|
for e in &test {
|
||||||
|
let (p0, p1, p2) = (rate, pr(&bp, &pos_cols, e), pr(&bf, &all, e));
|
||||||
|
lb += ll(p0, e.y); lp += ll(p1, e.y); lf += ll(p2, e.y);
|
||||||
|
pairs[0].push((p0, e.y)); pairs[1].push((p1, e.y)); pairs[2].push((p2, e.y));
|
||||||
|
}
|
||||||
|
tot_b += lb; tot_p += lp; tot_f += lf;
|
||||||
|
let n = test.len() as f64;
|
||||||
|
writeln!(md, "| {year} | {} | {:.0}% | {:.3} | {:.3} | {:.3} | {:+.3} | {:+.3} |", test.len(), 100.0 * test.iter().filter(|e| e.y).count() as f64 / n,
|
||||||
|
lb / n, lp / n, lf / n, 1.0 - lf / lb, 1.0 - lf / lp)?;
|
||||||
|
}
|
||||||
|
let ap = |mut v: Vec<(f64, bool)>| { v.sort_by(|a, b| b.0.total_cmp(&a.0)); let (mut h, mut s) = (0.0, 0.0); for (i, (_, y)) in v.iter().enumerate() { if *y { h += 1.0; s += h / (i as f64 + 1.0); } } if h > 0.0 { s / h } else { f64::NAN } };
|
||||||
|
writeln!(md, "\nAll years: skill of the full model {:+.3} vs base rate, {:+.3} vs entry position only. PR-AUC: base {:.3}, position {:.3}, full {:.3}.\n",
|
||||||
|
1.0 - tot_f / tot_b, 1.0 - tot_f / tot_p, ap(pairs[0].clone()), ap(pairs[1].clone()), ap(pairs[2].clone()))?;
|
||||||
|
// Coefficients on everything.
|
||||||
|
let mut d = Design::new(names.len());
|
||||||
|
for e in &ex { d.push(&e.x, e.y as i32 as f64, 1.0); }
|
||||||
|
let b = glm::logit(&d, 1.0);
|
||||||
|
writeln!(md, "| Feature (all years) | Coefficient |\n|---|---|")?;
|
||||||
|
for (n, w) in names.iter().zip(&b) { writeln!(md, "| {n} | {w:+.3} |")?; }
|
||||||
|
writeln!(md)?;
|
||||||
|
Ok(md)
|
||||||
|
}
|
||||||
@@ -3,14 +3,18 @@
|
|||||||
//!
|
//!
|
||||||
//! airplay model panel what the panel holds
|
//! airplay model panel what the panel holds
|
||||||
//! airplay model backtest [--h 1,4,8] [--refit 1] [--out docs/BACKTEST.md]
|
//! airplay model backtest [--h 1,4,8] [--refit 1] [--out docs/BACKTEST.md]
|
||||||
|
//! airplay model calibrate rotation thresholds from DR's lists -> docs/CALIBRATION.md
|
||||||
|
//! airplay model ifpi the 20-year IFPI test bed -> docs/IFPI.md
|
||||||
//! 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]
|
||||||
|
|
||||||
pub mod adds;
|
pub mod adds;
|
||||||
pub mod backtest;
|
pub mod backtest;
|
||||||
|
pub mod calibrate;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod features;
|
pub mod features;
|
||||||
pub mod glm;
|
pub mod glm;
|
||||||
|
pub mod ifpi;
|
||||||
pub mod kalman;
|
pub mod kalman;
|
||||||
pub mod panel;
|
pub mod panel;
|
||||||
pub mod rank;
|
pub mod rank;
|
||||||
@@ -53,6 +57,16 @@ pub fn run(db: &Db, args: &[String]) -> Result<()> {
|
|||||||
print!("{}", report.markdown);
|
print!("{}", report.markdown);
|
||||||
eprintln!("written to {out}");
|
eprintln!("written to {out}");
|
||||||
}
|
}
|
||||||
|
Some("ifpi") => {
|
||||||
|
let md = ifpi::run(db)?;
|
||||||
|
std::fs::write("docs/IFPI.md", &md)?;
|
||||||
|
print!("{md}");
|
||||||
|
}
|
||||||
|
Some("calibrate") => {
|
||||||
|
let md = calibrate::run(db, &p)?;
|
||||||
|
std::fs::write("docs/CALIBRATION.md", &md)?;
|
||||||
|
print!("{md}");
|
||||||
|
}
|
||||||
Some("adds") => {
|
Some("adds") => {
|
||||||
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();
|
||||||
let tau = common::thresholds(&p, 26);
|
let tau = common::thresholds(&p, 26);
|
||||||
|
|||||||
+4
-1
@@ -49,6 +49,8 @@ pub struct Panel {
|
|||||||
pub artists: Vec<Artist>,
|
pub artists: Vec<Artist>,
|
||||||
y: Vec<f32>,
|
y: Vec<f32>,
|
||||||
chart: Vec<Chart>,
|
chart: Vec<Chart>,
|
||||||
|
/// Rotation thresholds fitted to DR's rotation lists, if calibrated.
|
||||||
|
pub list_tau: Option<[u32; C]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Panel {
|
impl Panel {
|
||||||
@@ -111,7 +113,8 @@ impl Panel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let chart = chart_states(db, &weeks, &names, artists.len())?;
|
let chart = chart_states(db, &weeks, &names, artists.len())?;
|
||||||
Ok(Panel { weeks, artists, y, chart })
|
let list_tau = super::calibrate::stored(db)?;
|
||||||
|
Ok(Panel { weeks, artists, y, chart, list_tau })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -153,11 +153,14 @@ svg text { fill: var(--muted); font-size: 11px; }
|
|||||||
<p class="note prose">Walk-forward: for each week from week 27, the models are fitted only on what was known at the time and forecast 1, 4 and 8 weeks ahead. "Adds" are rows where the artist was not in rotation at the time of the forecast, which is the hard and interesting part. Skill above 0 means better than the baseline.</p>
|
<p class="note prose">Walk-forward: for each week from week 27, the models are fitted only on what was known at the time and forecast 1, 4 and 8 weeks ahead. "Adds" are rows where the artist was not in rotation at the time of the forecast, which is the hard and interesting part. Skill above 0 means better than the baseline.</p>
|
||||||
<div class="cards" id="cards"></div>
|
<div class="cards" id="cards"></div>
|
||||||
<div class="prose">
|
<div class="prose">
|
||||||
|
<h2>20 years of IFPI charts</h2>
|
||||||
|
<p>A second test, on the national charts: when a song enters the Track Top-40 without having been on the Airplay Top-20, does it reach the Airplay Top-20 within 8 weeks? Scored year by year from 2010, each year with a model fitted on the years before it. It beats the base rate by +0.13 in log-loss skill (PR-AUC 0.41 vs 0.20), and the strongest signal is the artist's own radio history: earlier Airplay Top-20 songs and how often their earlier hits crossed over.</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 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>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>Rotation thresholds are estimates</b> until DR's weekly rotation lists are parsed.</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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user