From 8803f26e7ad1fddcf0b964f6b88cbae6f3bdfa32 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 14 Jan 2016 09:04:16 +0000 Subject: [PATCH] Fix percentages for bayes confidence --- src/libstat/classifiers/bayes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c index 3204efc16..901e00a33 100644 --- a/src/libstat/classifiers/bayes.c +++ b/src/libstat/classifiers/bayes.c @@ -286,7 +286,11 @@ bayes_classify (struct rspamd_classifier * ctx, final_prob = 1.0 - final_prob; } - rspamd_snprintf (sumbuf, 32, "%.2f%%", final_prob * 100.); + /* + * Bayes p is from 0.5 to 1.0, but confidence is from 0 to 1, so + * we need to rescale it to display correctly + */ + rspamd_snprintf (sumbuf, 32, "%.2f%%", (final_prob - 0.5) * 200.); final_prob = bayes_normalize_prob (final_prob); g_assert (st != NULL); cur = g_list_prepend (NULL, sumbuf); -- 2.39.5