3 ms·
http://www.codeproject.com/KB/cs/BayesClassifier.aspx http://www.codeproject.com/KB/cs/BayesClassifier.aspx This is a simple one built in C#/.Net. I fixed a si
by jackbard 19y ago
http://www.codeproject.com/KB/cs/BayesClassifier.aspx http://www.codeproject.com/KB/cs/BayesClassifier.aspx
This is a simple one built in C#/.Net. I fixed a significant bug and raised classification accuracy from 74% -> 96% in my noisy dataset (automobile accident claims). I emailed the author with a bunch of improvements (such as histograms) and some other tweaks but never heard back. Anyway, the bugfix is simple: take a look at category.cs. In TeachPhrase(), move m_TotalWords++ inside the test for "if (!m_Phrases.TryGetValue(phrase, out pc))".
What you want here is to count the # of unique words. The original code was counting the total # of times all words appear.This one change reduced classification errors by 3X.
Cheers,
--Jack
- jackbard 19y agoOh, forgot to mention that you'll want to compute probabilities using logarithms to avoid underflow precision loss (which will introduce classification errors). example: wordValue = System.Math.Log((double)count / (double)cat.TotalWords);