Deezer discographies for every DR artist; release features in the add model (recency, releases in the window); rankings 'if they release in the window' and blended by release rate; site switch and what-if release toggle
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+17
-6
@@ -33,7 +33,9 @@ pub fn create_tables(db: &Db) -> Result<()> {
|
||||
"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, 'any' across channels;
|
||||
-- 'add' / 'add_any': P(new add in the 8 weeks from target_week);
|
||||
-- '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;
|
||||
-- '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
|
||||
@@ -119,12 +121,21 @@ 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;
|
||||
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])?;
|
||||
// If they release in the window, if they don't, and blended by their release rate.
|
||||
let t0 = p.w() - 1;
|
||||
let (pc1, pa1) = m.predict(p, &rot, a, t0, Some(true), None);
|
||||
let (pc0, pa0) = m.predict(p, &rot, a, t0, Some(false), None);
|
||||
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 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)?;
|
||||
if let Some(r) = pr { put("p_release", "any", r)?; }
|
||||
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])?;
|
||||
put("add", CHANNELS[c], mix(pc1[c], pc0[c]))?;
|
||||
put("add_rel", CHANNELS[c], pc1[c])?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user