Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Naive Bayes fail to solve XOR

Tags:

naivebayes

nlp

I have recently started understanding algorithms related to natural language processing, and have come across various sites which indicate that Naive Bayes cannot capture the XOR concept. Firstly I do not understand what exactly is the XOR problem. Can someone please explain, what the XOR problem is with a simple classification example if possible.

like image 394
qualitytest Avatar asked Jan 16 '17 18:01

qualitytest


People also ask

Why did Naive Bayes fail?

One of the disadvantages of Naïve-Bayes is that if you have no occurrences of a class label and a certain attribute value together then the frequency-based probability estimate will be zero. And this will get a zero when all the probabilities are multiplied.

Why does Naive Bayes give less accuracy?

The assumption that all features are independent is not usually the case in real life so it makes naive bayes algorithm less accurate than complicated algorithms.

How do I fix Naive Bayes problems?

Working of Naïve Bayes' Classifier: So to solve this problem, we need to follow the below steps: Convert the given dataset into frequency tables. Generate Likelihood table by finding the probabilities of given features. Now, use Bayes theorem to calculate the posterior probability.

Why does Naive Bayes work well with many features?

Because of the class independence assumption, naive Bayes classifiers can quickly learn to use high dimensional features with limited training data compared to more sophisticated methods. This can be useful in situations where the dataset is small compared to the number of features, such as images or texts.


1 Answers

The XOR problem is the most simple problem that is not linearly separable. Imagine you have two Boolean variables X and Y, and the target value you want to "predict" is the result from XORing the two variables. That is, only when either (but not the other) is 1, you want to predict 1 as outcome, and 0 otherwise. A bit more graphically:

Y ^
1 | XOR(x=0,y=1)=1  XOR(x=1,y=1)=0
  | 
0 | XOR(x=0,y=0)=0  XOR(x=1,y=0)=1
  +------------------------------->
           0               1      X

As you can see, for the four "points" of my "plot" above (X horizontally, Y vertically; imagine the commas are the "points", if you like), there is no way you can draw a straight line that separates the two outcomes (the two 1s in the upper left and lower right, and the two 0s, also in opposing corners). So linear classifiers, which model the class separation using straight lines, cannot solve problems of this nature.

Now, as to Naive Bayes, it models independent events. Given only X and Y, it can model the distribution of xs and it can model the ys, but it does not model any relation between the two variables. That is, to model the XOR function, the classifier would have to observe both variables at the same time. Only making a prediction based on the state of X without taking into account Y's state (and vice versa) cannot lead to a proper solution for this problem. Hence, the Naive Bayes classifier is a linear classifier, too.

like image 106
fnl Avatar answered Sep 29 '22 21:09

fnl