max / audiofiles
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 |