Release-week calendar: adjustable window (2-12 weeks, one release-event model each), time-since features moved to the release week, 'too soon' instead of special cases, season index (IFPI 2002-24) in the window; site: Best week tab, live ranking for any release week and window, single new-song view

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 12:24:01 +00:00
co-authored by Claude Opus 5.5
parent 347680bc9e
commit 3699944692
6 changed files with 369 additions and 154 deletions
+14 -11
View File
@@ -118,12 +118,15 @@ pub fn run(db: &Db, p: &Panel, max_h: usize, show_h: usize) -> Result<Vec<Line>>
// 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| {
// A new song released in week t0+h+1: time-since features moved forward to then; none if too
// soon after the artist's last release.
let event = |a: usize, h: usize| -> Option<([f64; C], f64, f64, f64)> {
if super::adds::too_soon(p, a, t0, h) { return None; }
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();
let (pcn, pan) = ev.predict_at(p, &rot, a, t0, h, Scenario::new(true, true).at(h), None);
let (pcr, par) = ev.predict_at(p, &rot, a, t0, h, Scenario::new(true, false).at(h), None);
Some((std::array::from_fn(|c| q * pcn[c] + (1.0 - q) * pcr[c]), q * pan + (1.0 - q) * par, pan, q))
};
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();
@@ -137,19 +140,19 @@ pub fn run(db: &Db, p: &Panel, max_h: usize, show_h: usize) -> Result<Vec<Line>>
let (pc0, pa0) = m.predict(p, &rot, a, t0, Scenario::new(false, 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 (ec, ea, ean, q, recent) = event[a];
let ev_a = event(a, h);
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", ea)?;
put("add_any_nmf", "any", ean)?;
put("p_nmf", "any", q)?;
if recent { put("recent_release", "any", 1.0)?; }
match ev_a {
Some((_, ea, ean, q)) => { put("add_any_rel", "any", ea)?; put("add_any_nmf", "any", ean)?; put("p_nmf", "any", q)?; }
None => { put("too_soon", "any", 1.0)?; }
}
if let Some(r) = pr { put("p_release", "any", r)?; }
for c in 0..C {
put("add", CHANNELS[c], mix(pc1[c], pc0[c]))?;
put("add_rel", CHANNELS[c], ec[c])?;
if let Some((ec, ..)) = ev_a { put("add_rel", CHANNELS[c], ec[c])?; }
}
}
}