diff --git a/apps/scene/src/faults.rs b/apps/scene/src/faults.rs index ab83c92e..bf1fe691 100644 --- a/apps/scene/src/faults.rs +++ b/apps/scene/src/faults.rs @@ -150,12 +150,24 @@ fn train(root: Option<&str>) -> Result { let m = Model::fit(&rest); held += ex.iter().filter(|e| &e.1 == *f && (m.score(&e.0, &e.1) >= FAULT) == (e.2 >= 0.5)).count(); } + // and a shot at a time (each project's own shot names, so a shot is a project's view): a scene it has never seen + let by_shot: Vec<_> = files.iter().enumerate().flat_map(|(n, f)| labels::shots(f).into_iter().map(move |(s, x, t, y)| (format!("{n}/{s}"), x, t, y))).collect(); + let mut names: Vec<&String> = by_shot.iter().map(|e| &e.0).collect(); + names.sort(); + names.dedup(); + let mut unseen = 0; + for s in &names { + let rest: Vec<_> = by_shot.iter().filter(|e| &e.0 != *s).map(|e| (e.1.clone(), e.2.clone(), e.3)).collect(); + let m = Model::fit(&rest); + unseen += by_shot.iter().filter(|e| &e.0 == *s && (m.score(&e.1, &e.2) >= FAULT) == (e.3 >= 0.5)).count(); + } Ok(format!( - "{} verdicts on {} findings from {} projects ({real} real, {} fine): the prior agreed with {before}, the fitted judge with {right}, and with {held} each fitted without its own finding (held out); kept in {}\n{}", + "{} verdicts on {} findings from {} projects ({real} real, {} fine): the prior agreed with {before}, the fitted judge with {right}, with {held} each fitted without its own finding (held out), and with {unseen} each fitted without its whole shot ({} shots, a scene it hasn't seen); kept in {}\n{}", ex.len(), finds.len(), files.len(), ex.len() - real, + names.len(), p.display(), crate::motion::train()? )) diff --git a/docs/manual/reference/cli/scene.md b/docs/manual/reference/cli/scene.md index a5227978..eca1359f 100644 --- a/docs/manual/reference/cli/scene.md +++ b/docs/manual/reference/cli/scene.md @@ -51,7 +51,7 @@ FAULT) and seen ones under that (maybe), counts the findings no camera sees, and with the finding's key. `--real KEY` and `--fine KEY` keep a verdict beside the project, and a finding the last run reported that is gone while both its parts remain is kept as fixed, so real. `raea scene faults train [FOLDER]` fits the model to every project's verdicts under FOLDER and keeps it in raea's models folder (notice/faults.json), which -every run after uses. Until then it judges by a written prior (systems/notice/src/model.rs). See docs/notice.feature. +every run after uses. It reports how many verdicts it gets right fitted without each one's finding, and without each one's whole shot (a scene it hasn't seen). Until then it judges by a written prior (systems/notice/src/model.rs). See docs/notice.feature. `faults --clip` holds a character's motion to what a body does, frame by frame (raea-sys-motionfaults): a knee that gives and comes back in a snap while its foot stands (a buckle), a standing foot that slides or glides along the diff --git a/docs/notice.feature b/docs/notice.feature index 9125779d..84193756 100644 --- a/docs/notice.feature +++ b/docs/notice.feature @@ -224,8 +224,8 @@ Feature: Notice: a 3D scene's faults judged as a viewer of the shot would see th lid, a sign's plate, a desk's top or meat on its tray; hanging lamps "in the air" on their rods; a dress form on its pole). The judge as it stood (22 verdicts, none from gambit) had called nearly all 41 faults, about 2 right: what it had learned from a motel didn't carry to a Berlin shop. Refitted on all 63 (14 real, 49 fine, 3 projects, 13 - shots), with each gambit shop left out and then judged: 34 of 41 right (a Python replay of the fit, every shot - held out in turn: 50 of 63). What it still gets wrong: floats by size (10 mm fine, 30 mm real, a 4 mm hat real; + shots), with each gambit shop left out and then judged: 34 of 41 right; every shot held out in turn, as `train` + now reports it: 51 of 63 (the prior: 18). What it still gets wrong: floats by size (10 mm fine, 30 mm real, a 4 mm hat real; seven verdicts don't fix a line, and the word "till" learned "fine" from the tills' shared faces), and the drugstore's scale, whose seam is truly hidden (it enters the till's far face) though the jam shows. Tried in the replay and not kept, none beating the fit as it stands by more than a verdict: the gap alone for floats, sunk and diff --git a/systems/notice/src/labels.rs b/systems/notice/src/labels.rs index f9aac1e5..df2a493a 100644 --- a/systems/notice/src/labels.rs +++ b/systems/notice/src/labels.rs @@ -106,6 +106,11 @@ pub fn files(root: &Path, depth: usize) -> Vec { /// A file's verdicts as examples, the newest verdict on each finding winning. pub fn examples(file: &Path) -> Vec<(Vec, Vec, f32)> { + shots(file).into_iter().map(|(_, x, t, y)| (x, t, y)).collect() +} + +/// The verdicts as `examples` reads them, each with the shot it was given on (for a fit held out a shot at a time). +pub fn shots(file: &Path) -> Vec<(String, Vec, Vec, f32)> { // per shot and key the newest verdict, a person's over a vision model's (`by: "ask"`) whatever their order let mut by: std::collections::BTreeMap, Vec, f32, bool)> = Default::default(); for line in std::fs::read_to_string(file).unwrap_or_default().lines() { @@ -122,5 +127,5 @@ pub fn examples(file: &Path) -> Vec<(Vec, Vec, f32)> { } by.insert(key, (x, toks, r["label"].as_f64().unwrap_or(0.0) as f32, asked)); } - by.into_values().map(|(x, t, y, _)| (x, t, y)).collect() + by.into_iter().map(|(k, (x, t, y, _))| (k.split('|').next().unwrap_or("").to_string(), x, t, y)).collect() }