Why multiply word count in text with probability of the occurrence of the word in the class

,

Screen Link:
https://app.dataquest.io/m/27/naive-bayes-for-sentiment-analysis/4/making-predictions-about-review-classifications

My Code:

 prediction *=  ((counts.get(word, 0) + 1) / (sum(counts.values()) + class_count))

What I expected to happen:

I expected this
 prediction *=  ((counts.get(word, 0) + 1) / (sum(counts.values()) + class_count))

What actually happened:

 prediction *=  text_counts.get(word) * ((counts.get(word, 0) + 1) / (sum(counts.values()) + class_count))

Why the probability was multiplied with text_counts.get(word) ?
Need some help to understand this.

1 Like

Hi @dash_sanjay,

That calculation is certainly not matching up with the comments in the answer. I will get it logged for review.

Thanks,
Sahil