Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no prior used in naive bayes classifier #4

Open
bmuller opened this issue Dec 2, 2010 · 1 comment

Comments

@bmuller
Copy link
Contributor

commented Dec 2, 2010

It looks like the prior probability for each classification is ignored in the Naive Bayes classifier. You should keep track of the number of times "train" is called with each class, and then use that to calculate the prior for each class: P(class) = # class trainings / # all trainings. You should then add Math.log(P(class)) to your log sum (score[category.to_s]) in your "classifications" method.

Without the addition of that prior you do not have a Naive Bayes classifier.

@cardmagic

This comment has been minimized.

Copy link
Owner

commented Dec 8, 2010

Please submit a patch. Thanks!

rroblak added a commit to rroblak/reclassifier that referenced this issue Apr 17, 2013

cardmagic pushed a commit that referenced this issue Dec 31, 2013

Lucas Carlson
Merge pull request #5 from bmuller/master
Fix for #4 - no prior used in Bayes Classifier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.