aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-15 12:32:57 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-15 13:34:42 +0100
commit73639d6543db207832f663a38bf299ff26bab8bb (patch)
tree3b27765a3ad0309f78e5bfd8ec81f39a713aafba /src/libstat
parent50ed1e6c5a60ca71fdfcf528f634ecc8cd266777 (diff)
downloadrspamd-73639d6543db207832f663a38bf299ff26bab8bb.tar.gz
rspamd-73639d6543db207832f663a38bf299ff26bab8bb.zip
[Minor] Make bayes normalization function public
Diffstat (limited to 'src/libstat')
-rw-r--r--src/libstat/classifiers/bayes.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c
index 35e061e08..07fe6cc86 100644
--- a/src/libstat/classifiers/bayes.c
+++ b/src/libstat/classifiers/bayes.c
@@ -165,27 +165,7 @@ bayes_classify_token (struct rspamd_classifier *ctx,
}
}
-/*
- * A(x - 0.5)^4 + B(x - 0.5)^3 + C(x - 0.5)^2 + D(x - 0.5)
- * A = 32,
- * B = -6
- * C = -7
- * D = 3
- * y = 32(x - 0.5)^4 - 6(x - 0.5)^3 - 7(x - 0.5)^2 + 3(x - 0.5)
- */
-static gdouble
-bayes_normalize_prob (gdouble x)
-{
- const gdouble a = 32, b = -6, c = -7, d = 3;
- gdouble xx, x2, x3, x4;
-
- xx = x - 0.5;
- x2 = xx * xx;
- x3 = x2 * xx;
- x4 = x3 * xx;
- return a*x4 + b*x3 + c*x2 + d*xx;
-}
gboolean
bayes_init (rspamd_mempool_t *pool, struct rspamd_classifier *cl)
@@ -308,7 +288,7 @@ bayes_classify (struct rspamd_classifier * ctx,
* 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);
+ final_prob = rspamd_normalize_probability (final_prob, 0.5);
g_assert (st != NULL);
cur = g_list_prepend (NULL, sumbuf);
rspamd_task_insert_result (task,