From: Vsevolod Stakhov Date: Thu, 23 May 2013 16:44:21 +0000 (+0100) Subject: Fix probability calculations. X-Git-Tag: 0.5.5~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9347b6450db4e7bc29a36fe84c72a1835d0f6cb6;p=thirdparty%2Frspamd.git Fix probability calculations. --- diff --git a/src/classifiers/bayes.c b/src/classifiers/bayes.c index 2a8ae44c72..24174187f0 100644 --- a/src/classifiers/bayes.c +++ b/src/classifiers/bayes.c @@ -169,7 +169,7 @@ bayes_classify_callback (gpointer key, gpointer value, gpointer data) spam_freq = ((double)spam_count / MAX (1., (double)cd->total_spam)); ham_freq = ((double)ham_count / MAX (1., (double)cd->total_ham)); spam_prob = spam_freq / (spam_freq + ham_freq); - bayes_spam_prob = (0.5 + spam_prob * total_count) / (double)total_count; + bayes_spam_prob = (0.5 + spam_prob * total_count) / (1. + total_count); cd->spam_probability += log (bayes_spam_prob); cd->ham_probability += log (1. - bayes_spam_prob); cd->processed_tokens ++;