diff options
-rw-r--r-- | src/libstat/classifiers/bayes.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c index 2e710522b..5295e018b 100644 --- a/src/libstat/classifiers/bayes.c +++ b/src/libstat/classifiers/bayes.c @@ -344,22 +344,22 @@ bayes_classify (struct rspamd_classifier * ctx, return TRUE; } - if (cl.spam_prob < -300 && cl.ham_prob < -300) { + if (cl.spam_prob > -300 && cl.ham_prob > -300) { /* Fisher value is low enough to apply inv_chi_square */ h = 1 - inv_chi_square (task, cl.spam_prob, cl.processed_tokens); s = 1 - inv_chi_square (task, cl.ham_prob, cl.processed_tokens); } else { /* Use naive method */ - if (cl.spam_prob > cl.ham_prob) { - s = (1.0 - exp(cl.spam_prob / cl.ham_prob)) / - (1.0 + exp(cl.spam_prob / cl.ham_prob)); - h = 1.0 - s; + if (cl.spam_prob < cl.ham_prob) { + h = (1.0 - exp(cl.spam_prob - cl.ham_prob)) / + (1.0 + exp(cl.spam_prob - cl.ham_prob)); + s = 1.0 - h; } else { - h = (1.0 - exp(cl.ham_prob / cl.spam_prob)) / - (1.0 + exp(cl.ham_prob / cl.spam_prob)); - s = 1.0 - h; + s = (1.0 - exp(cl.ham_prob - cl.spam_prob)) / + (1.0 + exp(cl.ham_prob - cl.spam_prob)); + h = 1.0 - s; } } |