I am making a spam filter for an assignment. One of the steps outlined in a paper that I have read indicates finding the mutual information for all the words in the text and then choosing the 500 or so with the highest MI.
The equation given in the paper (and elsewhere) is:
$MI(X_i, C) = \sum{P(X_i, C) \log{\frac{P(X_i, C)}{P(X_i)\cdot P(C)}}}$
where $X_i$ is a feature and $C$ is a class.
It is not clear in the paper but $X_i$ will be a word and $C$ will be either spam or not-spam.
Can I just be clear of the calculation that I should be doing? I think it is as follows for the word "viagra":
$P(X_i, C)$ in this case will be either the frequency that the word "viagra" appears in all of the spam emails divided by the number of words in the spam emails, or the same for the ham (non-spam) emails.
$P(X_i)$ is the probability of the word occurring at all in both spam and ham emails.
$P(C)$ is the prior for a class.
So basically we are doing two calculations (one for the spam and one for the ham) and adding them together.
Is this right do you think?
My understanding is that mutual information is like finding the information gain for a feature. Is this right?
Hope this makes sense. Many thanks in advance.