4
$\begingroup$

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)

https://www.google.com/url?q=https://blog.sicara.com/naive-bayes-classifier-sklearn-python-example-tips-42d100429e44&sa=D&source=hangouts&ust=1567686518476000&usg=AFQjCNGORHakHbk2ZntzNZ1wsTYG6QUhig

  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?

$\endgroup$
1
  • $\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

0
$\begingroup$

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

https://scikit-learn.org/stable/modules/generated/sklearn.naive_bayes.CategoricalNB.html

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

https://github.com/remykarem/mixed-naive-bayes

$\endgroup$

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.