我需要完成函数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)))