How do i use Naive Bayes Classifier (Using sklearn) for a Dataset considering that my feature set is categorical, ie more than 2 categories per feature are present.

  1. I've looked everywhere, some people have used GaussianNB even though the data is categorical (1,2...8)


  1. Some people recommend converting it to One-Hot encoding and then using BernoulliNB which doesn't make sense to me because then the newly created features would have a high correlation which is against one of the core assumptions of Naive Bayes. (For example color feature has 3 values - Blue, Green, Red and we create 3 features out of it; then if Blue is 1 then its obvious that Red and Green will be 0. Hence the dependency)

  2. Some people recommend using MultinomialNB which according to me doesn't make sense because it considers feature values to be frequency counts.

Can someone point me in the right direction?

  • $\begingroup$ Where is the problem with MultinominalNB? I don‘t see why it shouldn‘t work... $\endgroup$
    – Peter
    Commented Sep 5, 2019 at 16:23

1 Answer 1


In a recent scikit-learn release (v0.22.1), the developers have added Categorical Naive Bayes to their list of Naive Bayes implementations:


You could also use my implementation of categorical and/or Gaussian Naive Bayes:



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.