New-add model (add = entering rotation after 4+ weeks out; per channel and any DR channel, 8-week window), site ranks by it; DR rotation-list PDF parser (glyph positions, channel by play profile) and Wayback Machine backfill: 29 weekly lists 2023-2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+43
-1
@@ -7,6 +7,7 @@
|
||||
//! independent. Not yet conditioned on a release at t + h: that needs the release-effect curve
|
||||
//! from release dates (Deezer backfill). Until then this ranks expected airplay given current form.
|
||||
|
||||
use super::adds::{AddModel, Rot};
|
||||
use super::common::{thresholds, Direct, Rng};
|
||||
use super::features::P;
|
||||
use super::panel::{Panel, C, CHANNELS};
|
||||
@@ -31,7 +32,9 @@ pub fn create_tables(db: &Db) -> Result<()> {
|
||||
db.conn.execute_batch(
|
||||
"CREATE TABLE IF NOT EXISTS forecasts (
|
||||
made_at TEXT NOT NULL, model_version TEXT NOT NULL,
|
||||
target TEXT NOT NULL, -- 'rotation' (prob, mean plays) per channel, or '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);
|
||||
-- '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
|
||||
origin_week TEXT NOT NULL, target_week TEXT NOT NULL,
|
||||
@@ -105,5 +108,44 @@ pub fn run(db: &Db, p: &Panel, max_h: usize, show_h: usize) -> Result<Vec<Line>>
|
||||
eprintln!("rank: h={h} stored ({} artists)", lines.len());
|
||||
if h == show_h { shown = lines; }
|
||||
}
|
||||
// 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);
|
||||
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();
|
||||
let tx = db.conn.unchecked_transaction()?;
|
||||
{
|
||||
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;
|
||||
let (pc, pa) = m.predict(p, &rot, a, p.w() - 1, None);
|
||||
ins.execute(params![made, VERSION, "add_any", format!("{id}:any"), h as i64, origin.to_string(), start, pa,
|
||||
Option::<f64>::None, Option::<f64>::None, Option::<f64>::None])?;
|
||||
for c in 0..C {
|
||||
ins.execute(params![made, VERSION, "add", format!("{id}:{}", CHANNELS[c]), h as i64, origin.to_string(), start, pc[c],
|
||||
Option::<f64>::None, Option::<f64>::None, Option::<f64>::None])?;
|
||||
}
|
||||
}
|
||||
}
|
||||
tx.commit()?;
|
||||
eprintln!("rank: adds h={h} stored");
|
||||
}
|
||||
// Where each artist stands in the origin week: prob = 1 if in rotation, mean = plays.
|
||||
let tx = db.conn.unchecked_transaction()?;
|
||||
{
|
||||
let mut ins = tx.prepare("INSERT OR REPLACE INTO forecasts VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)")?;
|
||||
let t0 = p.w() - 1;
|
||||
for a in 0..p.a() {
|
||||
let id = &p.artists[a].id;
|
||||
for c in 0..C {
|
||||
let y = p.y(a, c, t0);
|
||||
if y == 0.0 { continue; }
|
||||
ins.execute(params![made, VERSION, "now", format!("{id}:{}", CHANNELS[c]), 0i64, origin.to_string(), origin.to_string(),
|
||||
rot.on(a, c, t0) as i32 as f64, y, Option::<f64>::None, Option::<f64>::None])?;
|
||||
}
|
||||
}
|
||||
}
|
||||
tx.commit()?;
|
||||
Ok(shown)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user