| #!/usr/bin/perl |
| |
| # This script extracts the confusion matrix (tp, tn, fp, fn) from the |
| # output of the fp-fn-statistics program. |
| # |
| # This is used by the validate-model script to aggregate the results of a |
| # cross validation for analysis with the compare-models script. |
| |
| use strict; |
| |
| foreach my $file (@ARGV) { |
| open (FILE, "<$file") || die $!; |
| |
| my ($tp, $tn, $fp, $fn); |
| |
| while (<FILE>) { |
| if ( /Correctly non-spam:\s*(\d+)/ ) { |
| $tn = $1; |
| } elsif ( /Correctly spam:\s*(\d+)/ ) { |
| $tp = $1; |
| } elsif ( /False positives:\s*(\d+)/ ) { |
| $fp = $1; |
| } elsif ( /False negatives:\s*(\d+)/ ) { |
| $fn = $1; |
| } |
| } |
| |
| close (FILE); |
| |
| printf "%d %d %d %d\n", $tn, $tp, $fp, $fn; |
| } |