|
From: <jgr...@us...> - 2003-09-04 16:31:26
|
Update of /cvsroot/popfile/engine/Classifier
In directory sc8-pr-cvs1:/tmp/cvs-serv7999/Classifier
Modified Files:
Bayes.pm
Log Message:
Use the same combining method as SpamBayes to take the two chi2 calculations and come up with a certainty value
Index: Bayes.pm
===================================================================
RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v
retrieving revision 1.185
retrieving revision 1.186
diff -C2 -d -r1.185 -r1.186
*** Bayes.pm 4 Sep 2003 13:31:06 -0000 1.185
--- Bayes.pm 4 Sep 2003 16:30:41 -0000 1.186
***************
*** 613,617 ****
}
! return $sum;
}
--- 613,617 ----
}
! return ($sum<1)?$sum:1;
}
***************
*** 719,723 ****
foreach my $bucket (@buckets) {
! $chi{$bucket} = chi2( $score{$bucket}, 2 * $matchcount{$ranking[0]}, -int($score{$ranking[0]}/log(10)) * log(10) );
}
--- 719,723 ----
foreach my $bucket (@buckets) {
! $chi{$bucket} = chi2( $score{$bucket}, 2 * $matchcount{$bucket}, -int($score{$ranking[0]}/log(10)) * log(10) );
}
***************
*** 732,736 ****
# we are unsure
! if ( ( $chi{$ranking[0]} * 0.5 ) < $chi{$ranking[1]} ) {
$class = 'unsure';
}
--- 732,741 ----
# we are unsure
! my $c0 = 1.0 - $chi{$ranking[0]};
! my $c1 = 1.0 - $chi{$ranking[1]};
!
! my $certainty = ($c1-$c0 + 1) / 2;
!
! if ( $certainty < 0.9 ) {
$class = 'unsure';
}
***************
*** 780,784 ****
}
! $self->{scores__} .= "<hr><b>$language{Scores}</b><p>\n<b>Verdict: <font color=\"$self->{colors__}{$class}\">$class</font></b><p>\n<table class=\"top20Words\">\n<tr>\n<th scope=\"col\">$language{Bucket}</th>\n<th> </th>\n";
$self->{scores__} .= "<th scope=\"col\">$language{Count} </th><th scope=\"col\">$language{Probability}</th></tr>\n";
--- 785,789 ----
}
! $self->{scores__} .= "<hr><b>$language{Scores}</b><p>\n<b>Verdict: <font color=\"$self->{colors__}{$class}\">$class ($certainty)</font></b><p>\n<table class=\"top20Words\">\n<tr>\n<th scope=\"col\">$language{Bucket}</th>\n<th> </th>\n";
$self->{scores__} .= "<th scope=\"col\">$language{Count} </th><th scope=\"col\">$language{Probability}</th></tr>\n";
|