[Spambayes-checkins] spambayes weaktest.py,1.3,1.4
Rob W.W. Hooft
hooft@users.sourceforge.net
Sat Nov 16 05:42:37 2002
Update of /cvsroot/spambayes/spambayes
In directory usw-pr-cvs1:/tmp/cvs-serv3886
Modified Files:
weaktest.py
Log Message:
Use the CostCounter
Index: weaktest.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/weaktest.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** weaktest.py 10 Nov 2002 19:59:22 -0000 1.3
--- weaktest.py 16 Nov 2002 05:42:35 -0000 1.4
***************
*** 34,37 ****
--- 34,38 ----
import msgs
+ import CostCounter
program = sys.argv[0]
***************
*** 58,61 ****
--- 59,63 ----
nham = len(hamfns)
nspam = len(spamfns)
+ cc = CostCounter.default()
allfns = {}
***************
*** 71,78 ****
fp = 0
fn = 0
- flexcost = 0
- FPW = options.best_cutoff_fp_weight
- FNW = options.best_cutoff_fn_weight
- UNW = options.best_cutoff_unsure_weight
SPC = options.spam_cutoff
HC = options.ham_cutoff
--- 73,76 ----
***************
*** 88,95 ****
if debug:
print "score:%.3f"%scr,
if scr < SPC and is_spam:
- t = FNW * (SPC - scr) / (SPC - HC)
- #print "Spam at %.3f costs %.2f"%(scr,t)
- flexcost += t
if scr < HC:
fn += 1
--- 86,94 ----
if debug:
print "score:%.3f"%scr,
+ if is_spam:
+ cc.spam(scr)
+ else:
+ cc.ham(scr)
if scr < SPC and is_spam:
if scr < HC:
fn += 1
***************
*** 104,110 ****
d.update_probabilities()
elif scr > HC and not is_spam:
- t = FPW * (scr - HC) / (SPC - HC)
- #print "Ham at %.3f costs %.2f"%(scr,t)
- flexcost += t
if scr > SPC:
fp += 1
--- 103,106 ----
***************
*** 131,136 ****
print "Trained on %d ham and %d spam"%(hamtrain, spamtrain)
print "fp: %d fn: %d"%(fp, fn)
! print "Total cost: $%.2f"%(FPW * fp + FNW * fn + UNW * unsure)
! print "Flex cost: $%.4f"%flexcost
def main():
--- 127,131 ----
print "Trained on %d ham and %d spam"%(hamtrain, spamtrain)
print "fp: %d fn: %d"%(fp, fn)
! print cc
def main():
More information about the Spambayes-checkins
mailing list