stat calculation updates

This commit is contained in:
2024-06-17 21:54:13 +02:00
parent a98eaeb30e
commit 5e6a6c62bf
4 changed files with 40 additions and 19 deletions
+19 -10
View File
@@ -59,9 +59,9 @@ impl PRStats {
let r = tpos / (tpos + fneg);
(r, p)
}
pub fn pr_curve(&self) -> Vec<(f64, f64)> {
pub fn pr_curve(&self, threshold: usize) -> Vec<(f64, f64)> {
let mut curve = Vec::new();
for i in 0..64 {
for i in 0..threshold {
curve.push(self.pr(i));
}
curve
@@ -340,6 +340,7 @@ impl DescriptorStore {
);
}
// Seen should only contain a list of base images
let set = self.seen.clone().unwrap();
for image in set.iter() {
let phash = self.get(image).unwrap();
@@ -349,25 +350,33 @@ impl DescriptorStore {
//Assume miss, therefore a false negative
//Undo the miss when there is a true positive
for mutator in &mut mutator_stats {
mutator.false_negatives[threshold as usize] += 1;
mutator.false_negatives[threshold] += 1;
}
for found in self.nn_flat_results(phash, threshold) {
if found.eq(image) || found.ends_with(&format!(".{}", image)) { // True positive
if found.ends_with(&format!(".{}", image)) { // True positive
for mutator in &mut mutator_stats {
if found.starts_with(&mutator.tag) {
debug!("{} is hit for {}", found, mutator.name);
mutator.true_positives[threshold as usize] += 1;
mutator.false_negatives[threshold as usize] -= 1;
mutator.true_positives[threshold] += 1;
mutator.false_negatives[threshold] -= 1;
}
}
} else if found.eq(image) {
continue;
} else { // False positive!
// Mutated misses only count for the mutator
// Unmutated misses count for everyone
for mutator in &mut mutator_stats {
if found.starts_with(&mutator.tag) || !found.starts_with("mut") {
debug!("{} is false positive for {}", found, mutator.name);
mutator.false_positives[threshold as usize] += 1;
if found.starts_with("mut") {
for mutator in &mut mutator_stats {
if found.starts_with(&mutator.tag) {
debug!("{} is false positive for {}", found, mutator.name);
mutator.false_positives[threshold] += 1;
}
}
} else {
for mutator in &mut mutator_stats {
mutator.false_positives[threshold] += 1;
}
}
}