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

Chapter 4 - Classifying with probability theory: naïve Bayes #20

Open
noisytoken opened this issue Oct 20, 2020 · 1 comment
Open

Chapter 4 - Classifying with probability theory: naïve Bayes #20

noisytoken opened this issue Oct 20, 2020 · 1 comment

Comments

@noisytoken
Copy link

noisytoken commented Oct 20, 2020

When we attempt to classify a document, we multiply a lot of probabilities together to
get the probability that a document belongs to a given class. This will look something
like p(w0|1)p(w1|1)p(w2|1). If any of these numbers are 0, then when we multiply
them together we get 0. To lessen the impact of this, we’ll initialize all of our occurrence counts to 1, and we’ll initialize the denominators to 2

First of all, huge thanks for creating an understandable ML book.

Coming back to question now:

I perfectly, understood the idea behind setting p0Num and p1Num to np.ones, but why you have set p0Denom and p1Denom both to 2?

@JPL-JUNO
Copy link

In my opinion, it should be set to the length of the myVocabList multiplied by 1.
p0Denom = sum(p0Num) p1Denom = sum(p1Num)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants