我已经尝试了现有的解决方案,但无法解决这个问题。在
原代码:
prob = n / self.totaldocs # 0.7445791360764896
self.classpriorprob[cls] = math.log(prob)
解决方案:(但我更喜欢使用普通日志)
^{pr2}$如前所述here:我试图将数字四舍五入到小数点后3位。在
prob = n / self.totaldocs
number = round(prob, 3) # 0.744
self.classpriorprob[cls] = math.log(number)
但我仍然得到数学领域的错误。在
编辑:我直接传递了值,即。数学日志(0.744)并且有效。 当我尝试的时候它也有用数学日志()函数。在
请告知。在
规格:
python 3.6.3
皮查姆
尝试使用log sum exp技巧:
我得到了0.0。在
在我的例子中,解决方案是跳过0.0值。在
相关问题 更多 >
编程相关推荐