Skip to main content

max / audiofiles

Scope the bench drum-detection metric to drum-expected samples The "Layer 1 accuracy (drum detection)" line counted is_drum_class(predicted) across every result without consulting expected, so a non-drum sample predicted as a drum counted as correct. Its own comment already claimed the narrower thing: "predicted is any drum class when expected is drum". Masked exactly by the corpus: expected_class_from_dir maps only the seven drum classes and is_drum_class covers exactly those seven, so the subset is the whole set and today's 89.4% is unchanged. It stops being wrong the moment a non-drum class enters the corpus, which the correctness thread will do. The printed fraction now carries the same denominator as the percentage rather than total_classified, which would have disagreed once the two diverge.
Author: Max Johnson <me@maxj.phd> · 2026-07-29 18:04 UTC
Signed with PGP, not checked
Commit: 8addfeb0e3a7f18a51dcbd2582c5927da57a7589
Parent: a436e63
1 file changed, +20 insertions, -4 deletions
@@ -738,19 +738,35 @@
738 738 .count();
739 739 let strict_acc = strict_correct as f64 / total_classified as f64 * 100.0;
740 740
741 - // Layer 1 accuracy: predicted is any drum class when expected is drum
742 - let drum_correct = all_results
741 + // Layer 1 accuracy: predicted is any drum class when expected is drum.
742 + //
743 + // Scoped to the drum-expected subset, which is what the name claims. It
744 + // previously counted is_drum_class(predicted) over every result without
745 + // consulting expected at all, so a non-drum sample predicted as a drum
746 + // scored as correct. The corpus is currently 100% drums, which masked it
747 + // exactly; the number is unchanged today and stops being wrong the moment
748 + // a non-drum class enters the corpus.
749 + let drum_expected: Vec<&ClassifyResult> = all_results
750 + .iter()
751 + .filter(|r| is_drum_class(r.expected))
752 + .collect();
753 + let drum_correct = drum_expected
743 754 .iter()
744 755 .filter(|r| is_drum_class(r.predicted))
745 756 .count();
746 - let drum_acc = drum_correct as f64 / total_classified as f64 * 100.0;
757 + let drum_acc = if drum_expected.is_empty() {
758 + 0.0
759 + } else {
760 + drum_correct as f64 / drum_expected.len() as f64 * 100.0
761 + };
747 762
748 763 println!(" Overall:");
749 764 println!(
750 765 " Strict accuracy (exact class match): {strict_acc:.1}% ({strict_correct}/{total_classified})"
751 766 );
752 767 println!(
753 - " Layer 1 accuracy (drum detection): {drum_acc:.1}% ({drum_correct}/{total_classified})"
768 + " Layer 1 accuracy (drum detection): {drum_acc:.1}% ({drum_correct}/{})",
769 + drum_expected.len()
754 770 );
755 771 println!();
756 772