From: Vsevolod Stakhov Date: Sun, 9 Oct 2016 19:54:10 +0000 (+0100) Subject: [Feature] Add support of min_learns to neural net classifier X-Git-Tag: 1.4.0~294 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ba01e88c8520cc09be7c2f0a387d76c6be04b08f;p=rspamd.git [Feature] Add support of min_learns to neural net classifier --- diff --git a/src/plugins/lua/fann_scores.lua b/src/plugins/lua/fann_scores.lua index c67eb597d..82b0d658c 100644 --- a/src/plugins/lua/fann_scores.lua +++ b/src/plugins/lua/fann_scores.lua @@ -727,6 +727,24 @@ if redis_params then rspamd_classifiers['neural'] = { classify = function(task, classifier, tokens) local function classify_cb(task) + local min_learns = classifier:get_param('min_learns') + + if min_learns then + min_learns = tonumber(min_learns) + end + + if min_learns and min_learns > 0 then + if current_classify_ann.ham_learned < min_learns or + current_classify_ann.spam_learned < min_learns then + + rspamd_logger.infox(task, 'fann classifier has not enough learns: (%s spam, %s ham), %s required', + current_classify_ann.spam_learned, current_classify_ann.ham_learned, + min_learns) + return + end + end + + -- Perform classification local vec = tokens_to_vector(tokens) add_metatokens(task, vec) local out = current_classify_ann.ann:test(vec)