# How to use Naive Bayes for multi class problems?

I know how Naive Bayes work for classifying binary problems. I just need to know what are the standard way to apply NB on multi-class classification problems. Any idea please?

## 1 Answer

Unlike some classifiers, multi-class labeling is trivial with Naive Bayes.

For each test example $$i$$, and each class $$k$$ you want to find: $$\arg \max_k P(\textrm{class}_k | \textrm{data}_i)$$

In other words, you compute the probability of each class label in the usual way, then pick the class with the largest probability.

• Thank you Matt. As you said, it is pretty straightforward. While I think this would not be the case with SVM for example. – Mohammadreza Mar 25 '15 at 3:30
• My pleasure. For other methods, there are (many) ways of combining two-way classifiers (like SVMs) into a multi-class system. I think there has also been some work on extending SVMs to do this "natively." – Matt Krause Mar 25 '15 at 15:52