朴素贝叶斯分类器-对数概率

时间:2020-02-13 11:01:13

标签: classification naivebayes logarithm

我需要完成函数log_probability,该函数使用add-λ根据语料库单词计数中单词出现的次数,词汇大小vocab_size和所有单词出现总数的和来计算单词的对数概率平滑(浮动)。

我尝试的代码如下,但是没有用。

def log_probability(self, wordcount, vocab_size, total, smoothing):

    return math.log((log_probability(wordcount + smoothing) - math.log(vocab_size + total * smoothing)))

0 个答案:

没有答案