# How do you unify probability (Naive Bayes)?

In the blog found here:

the author discusses sentiment analysis with Naive Bayes. He uses Naive Bayes to predict if a tweet is happy or sad, but instead of the prediction being a binary value he produces the probability of happiness. He combines the probability of happy and the probability of sad into one probability.

His formula is such:

w = set of words

s = set of categories (only happy and sad)

$$p(s \mid \bar{w}) = \left( \sum_{s'} \exp \left( \sum_{w \in \bar{w}} \log p(w, s') - \log p(w,s) - \log p(s') + \log p(s)\right) \right)^{-1}$$

$$p(\mathrm{happy} \mid \bar{w}) = \left( \exp \left( \sum_{w \in \bar{w}} \log p(w, \mathrm{sad}) - \log p(w, \mathrm{happy})\right) + 1\right)^{-1}$$

Why does the math transform the two log probabilities to p(happy | w)? Doesn't subtracting the logs give you the ratio of sad to happy?

-
Do you know Naive Bayes? Did you follow the working that the author of the blog shows in his blog post? –  TenaliRaman Jul 14 '12 at 4:10
I haven't read it but I know if there is independency condition, then likelihood ratios are summable. This means your assertion can be correct iff the observations, in this case the words, are independent of each other. If this is not the case. There will be some additional terms taking into account the correlations. In case of correlations, the overall accuracy of the system to estimate the level of happiness will degrade compared to independent case. I hope it helps. –  Seyhmus Güngören Jul 15 '12 at 12:21