[Spambayes-checkins] spambayes Options.py,1.8,1.9
timtest.py,1.19,1.20
Tim Peters
tim_one@users.sourceforge.net
Tue, 10 Sep 2002 17:22:59 -0700
Update of /cvsroot/spambayes/spambayes
In directory usw-pr-cvs1:/tmp/cvs-serv26264
Modified Files:
Options.py timtest.py
Log Message:
Added options
[TestDriver]
save_trained_pickles: False
pickle_basename: class
Index: Options.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Options.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Options.py 10 Sep 2002 18:15:48 -0000 1.8
--- Options.py 11 Sep 2002 00:22:56 -0000 1.9
***************
*** 57,61 ****
[TestDriver]
! # These control various displays in class Drive (timtest.py).
# Number of buckets in histograms.
--- 57,61 ----
[TestDriver]
! # These control various displays in class Driver (timtest.py).
# Number of buckets in histograms.
***************
*** 74,77 ****
--- 74,88 ----
show_false_negatives: False
show_best_discriminators: True
+
+ # If save_trained_pickles is true, Driver.train() saves a binary pickle
+ # of the classifier after training. The file basename is given by
+ # pickle_basename, the extension is .pik, and increasing integers are
+ # appended to pickle_basename. By default (if save_trained_pickles is
+ # true), the filenames are class1.pik, class2.pik, ... If a file of that
+ # name already exists, it's overwritten. pickle_basename is ignored when
+ # save_trained_pickles is false.
+
+ save_trained_pickles: False
+ pickle_basename: class
"""
***************
*** 79,82 ****
--- 90,94 ----
float_cracker = ('getfloat', None)
boolean_cracker = ('getboolean', bool)
+ string_cracker = ('get', None)
all_options = {
***************
*** 95,98 ****
--- 107,112 ----
'show_histograms': boolean_cracker,
'show_best_discriminators': boolean_cracker,
+ 'save_trained_pickles': boolean_cracker,
+ 'pickle_basename': string_cracker,
},
}
Index: timtest.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/timtest.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** timtest.py 10 Sep 2002 01:53:12 -0000 1.19
--- timtest.py 11 Sep 2002 00:22:56 -0000 1.20
***************
*** 152,155 ****
--- 152,156 ----
self.global_ham_hist = Hist(options.nbuckets)
self.global_spam_hist = Hist(options.nbuckets)
+ self.ntimes_train_called = 0
def train(self, ham, spam):
***************
*** 164,172 ****
self.trained_spam_hist = Hist(options.nbuckets)
! #f = file('w.pik', 'wb')
! #pickle.dump(self.classifier, f, 1)
! #f.close()
! #import sys
! #sys.exit(0)
def finishtest(self):
--- 165,176 ----
self.trained_spam_hist = Hist(options.nbuckets)
! self.ntimes_train_called += 1
! if options.save_trained_pickles:
! fname = "%s%d.pik" % (options.pickle_basename,
! self.ntimes_train_called)
! print " saving pickle to", fname
! fp = file(fname, 'wb')
! pickle.dump(self.classifier, fp, 1)
! fp.close()
def finishtest(self):