[Spambayes-checkins] spambayes/spambayes Stats.py,1.15,1.16

Tony Meyer anadelonbrin at users.sourceforge.net
Wed Apr 6 04:42:07 CEST 2005


Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4161/spambayes

Modified Files:
	Stats.py 
Log Message:
Allow the RecordTraining method to be given the old class as a string as well as as
 a score.

Index: Stats.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/Stats.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Stats.py	20 Jan 2005 03:47:42 -0000	1.15
--- Stats.py	6 Apr 2005 02:42:04 -0000	1.16
***************
*** 78,81 ****
--- 78,82 ----
  
      def RecordClassification(self, score):
+         """Record that a message has been classified this session."""
          if score >= self.options["Categorization", "spam_cutoff"]:
              self.num_spam += 1
***************
*** 85,94 ****
              self.num_ham += 1
  
!     def RecordTraining(self, as_ham, old_score):
          if as_ham:
              self.num_trained_ham += 1
              # If we are recovering an item that is in the "spam" threshold,
              # then record it as a "false positive"
!             if old_score > self.options["Categorization", "spam_cutoff"]:
                  self.num_trained_ham_fp += 1
          else:
--- 86,108 ----
              self.num_ham += 1
  
!     def RecordTraining(self, as_ham, old_score=None, old_class=None):
!         """Record that a message has been trained this session.
! 
!         If old_score and old_class are None, then the message had not
!         previously been trained (e.g. using the "Train" box on the web
!         interface), and so cannot be considered a fp or fn).
! 
!         If both old_score and old_class are specified, old_score is used.
!         """
!         # XXX Why, oh why, does this function have as_ham, when every
!         # XXX other function has isSpam???
          if as_ham:
              self.num_trained_ham += 1
              # If we are recovering an item that is in the "spam" threshold,
              # then record it as a "false positive"
!             if old_score is not None and \
!                old_score > self.options["Categorization", "spam_cutoff"]:
!                 self.num_trained_ham_fp += 1
!             elif old_class == self.options["Headers", "header_spam_string"]:
                  self.num_trained_ham_fp += 1
          else:
***************
*** 96,100 ****
              # If we are deleting as Spam an item that was in our "good"
              # range, then record it as a false negative.
!             if old_score < self.options["Categorization", "ham_cutoff"]:
                  self.num_trained_spam_fn += 1
  
--- 110,117 ----
              # If we are deleting as Spam an item that was in our "good"
              # range, then record it as a false negative.
!             if old_score is not None and \
!                old_score < self.options["Categorization", "ham_cutoff"]:
!                 self.num_trained_spam_fn += 1
!             elif old_class == self.options["Headers", "header_ham_string"]:
                  self.num_trained_spam_fn += 1
  



More information about the Spambayes-checkins mailing list