diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-10 20:38:24 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-10 20:38:24 +0100 |
commit | 1e185524aab1ef6387a96902c41291ea5cc0ffec (patch) | |
tree | 2e3f68d69cb3a704c2437d5a8386461622a1f1e6 /src/libstat/classifiers | |
parent | 26f0b37daaf61a48c8af846bbbf981c21d43a1bf (diff) | |
download | rspamd-1e185524aab1ef6387a96902c41291ea5cc0ffec.tar.gz rspamd-1e185524aab1ef6387a96902c41291ea5cc0ffec.zip |
[Minor] Use log2 as it is slightly faster
Diffstat (limited to 'src/libstat/classifiers')
-rw-r--r-- | src/libstat/classifiers/bayes.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c index 40dcdf36f..35e061e08 100644 --- a/src/libstat/classifiers/bayes.c +++ b/src/libstat/classifiers/bayes.c @@ -140,6 +140,7 @@ bayes_classify_token (struct rspamd_classifier *ctx, fw = feature_weight[tok->window_idx % G_N_ELEMENTS (feature_weight)]; norm_sum = (spam_freq + ham_freq) * (spam_freq + ham_freq); norm_sub = (spam_freq - ham_freq) * (spam_freq - ham_freq); + w = (norm_sub) / (norm_sum) * (fw * total_count) / (4.0 * (1.0 + fw * total_count)); bayes_spam_prob = PROB_COMBINE (spam_prob, total_count, w, 0.5); @@ -147,8 +148,9 @@ bayes_classify_token (struct rspamd_classifier *ctx, w = (norm_sub) / (norm_sum) * (fw * total_count) / (4.0 * (1.0 + fw * total_count)); bayes_ham_prob = PROB_COMBINE (ham_prob, total_count, w, 0.5); - cl->spam_prob += log (bayes_spam_prob); - cl->ham_prob += log (bayes_ham_prob); + + cl->spam_prob += log2 (bayes_spam_prob); + cl->ham_prob += log2 (bayes_ham_prob); cl->processed_tokens ++; msg_debug_bayes ("token: weight: %f, total_count: %L, " |