0
$\begingroup$

Why there is no alpha argument ( smoothing parameter in Laplace smoothing) for GaussianNB() in sklearn library? ? Although BernoulliNB() and MultinomialNB() have an alpha parameter but GaussianNB() doesn't have ?

$\endgroup$

1 Answer 1

1
$\begingroup$

Because smoothing makes sense only for BernoulliNB and MultinomialNB, which have categorical features, whereas GaussianNB works with numerical features which are supposed to follow a normal distribution.

For BernoulliNB and MultinomialNB, the features often represent frequencies and can be zero. In theory, this can cause one or several of the conditional probabilities to be zero, and therefore occasionally make the posterior probability zero. It can even cause the posterior to be zero for all the classes, an inconsistency. Smoothing prevents these issues.

In GaussianNB the conditional probability is calculated from the normal distribution so they can never be zero, thus this problem cannot happen.

$\endgroup$
2
  • $\begingroup$ What confuses me is that the probability that a continuous random variable equals some value is always zero , like here stats.stackexchange.com/questions/60702/… $\endgroup$
    – AAA
    Commented Oct 11, 2022 at 22:58
  • $\begingroup$ @AAA As far as I remember this is usually handled by taking the probability of the interval around the value instead, i.e. instead of calculating $p(x)$ one calculates $p(x \in [x-\epsilon/2, x+\epsilon/2])$ with $\epsilon$ a fixed constant, e.g. 0.000001. This would be specific to GaussianNB of course. $\endgroup$
    – Erwan
    Commented Oct 12, 2022 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.