"sklearn/naive_bayes.py" 说
# If the ratio of data variance between dimensions is too small, it # will cause numerical errors. To address this, we artificially # boost the variance by epsilon, a small fraction of the standard # deviation of the largest dimension.
有人可以举一个例子来说明这种由小方差引起的数值误差?
朴素贝叶斯与概率一起工作。概率通常很小。要计算联合概率,您需要将概率相乘。当你将一个小数乘以另一个小数时,你会得到一个非常小的数字(有时甚至不适合 32 位浮点值,非零值变成 0(。
有时,某些特征的方差为 0,这会导致div 为零问题和数值不稳定。