[Spambayes] AssertionError: hamcount <= nham

papaDoc papaDoc at videotron.ca
Wed Nov 19 09:08:35 EST 2003


Hi,

>Hi,
>
>whenever I untrain a spam message accidantly trained as ham, by
>database gets corrupted. I get the following error message:
>
>Traceback (most recent call last):
>  File "/usr/local/bin/sb_filter.py", line 203, in ?
>    main()
>  File "/usr/local/bin/sb_filter.py", line 199, in main
>    action(msg)
>  File "/usr/local/bin/sb_filter.py", line 132, in filter
>    return h.filter(msg)
>  File "/usr/local/lib/python2.3/site-packages/spambayes/hammie.py", line 109, in filter
>    prob, clues = self._scoremsg(msg, True)
>  File "/usr/local/lib/python2.3/site-packages/spambayes/hammie.py", line 38, in _scoremsg
>    return self.bayes.spamprob(tokenize(msg), evidence)
>  File "/usr/local/lib/python2.3/site-packages/spambayes/classifier.py", line 158, in chi2_spamprob
>    clues = self._getclues(wordstream)
>  File "/usr/local/lib/python2.3/site-packages/spambayes/classifier.py", line 395, in _getclues
>    prob = self.probability(record)
>  File "/usr/local/lib/python2.3/site-packages/spambayes/classifier.py", line 242, in probability
>    assert hamcount <= nham
>AssertionError
>  
>
This can occur for all db available.

When Spambayes train on a email it is adding a
X-Spambayes-train: spam or ham (or something similar)
in the header.

When you untrain it check this header and remove the email token from 
the "spam/ham" part of the database.
You can have the problem if the email was training with a database then 
you delete this database.
You start with a new database and try to train again with the email you 
already train on.
Since the email still have the X-Spambayes-train header you don't train 
on with it except if you force the training (the -f options)
If later you find a mistake and you untrain. with the above email. Since 
it was never really train with the later database the
hamcount or spamcount can co negative.

So start again and force the training on all message
sb_mboxtrain -f -g you_ham_mbox -s your_spam_mbox
You will be able to correct your mistake.


Remi




More information about the Spambayes mailing list