Naive Bayes Classifier: Only get 30-40% accuracy on iris data set
<p>I'm trying to implement Naive Bayes Classifier in python for the last few days with the iris data set from UCI (<a href="http://archive.ics.uci.edu/ml/datasets/Iris" rel="nofollow">http://archive.ics.uci.edu/ml/datasets/Iris</a>). When trying to classify 100 random samples i get only 30-40% accuracy. I think my probability function is right because I tested it with the example from wikipedia (<a href="https://en.wikipedia.org/wiki/Naive_Bayes_classifier#Examples" rel="nofollow">https://en.wikipedia.org/wiki/Naive_Bayes_classifier#Examples</a>) </p>

<p>Now here's what I do:</p>

<ul>
<li>I load the data</li>
<li>I divide the data into 3 classes</li>
<li>I calculate the mean and variance for each class</li>
</ul>

<p>Then for 100 random samples I:</p>

<ul>
<li>calculate the probability for each feature to belong to a class</li>
<li><p>Calculate the posterior numerator by multiplying each probability for that class</p></li>
<li><p>Store the values in a list and get the index of the highest value</p></li>
<li><p>compare the highest value index to the real index (Check if prediction is right)</p></li>
</ul>

<p>And somehow I only get 30-40%, am I doing something wrong?</p>

<p>If you want to see the code, it's here: <a href="http://pastebin.com/sUYm97qi" rel="nofollow">http://pastebin.com/sUYm97qi</a></p>