Given two random variables X and Y, mutual information measures how much knowing one of these variables reduces uncertainty about the other. For example, if X and Y are independent, then knowing X does not give any information about Y and vice-verse, so their mutual information is zero. At the other extreme, if X is a deterministic function of Y and Y is a deterministic function of X then all information conveyed by X is shared with Y, i.e. knowing X determines the value of Y and vice-verse. If the variable X takes on the values {x_{1}, x_{2}, …} and Y takes on the values {y_{1}, y_{2}, …} then the mutual information of X and Y is denoted as the expected value of the point-wise mutual information i.e. log (P(X=x_{i}, Y=y_{j})/P(X=x_{i})P(Y=y_{j}))

MI (X, Y) = ∑ P(X=x_{i}, Y=y_{j}) * log (P(X=x_{i}, Y=y_{j})/P(X=x_{i})P(Y=y_{j})) ∀ (X=x_{i}, Y=y_{j})

All log values in further calculations are taken base 2.

If X and Y are mutually independent then for every (X=x_{i}, Y=y_{j}), P(X=x_{i}, Y=y_{j}) = P(X=x_{i})P(Y=y_{j}) and hence log 1 = 0. Mutual Information is also related to the entropy (uncertainty of the random variables) :

MI (X, Y) = H(Y) – H(Y|X) = H(X) – H(X|Y)

where H(Y) is the entropy(uncertainty) of the variable Y, H(Y|X) is the remaining uncertainty in Y after knowing X. Hence H(Y) – H(Y|X) is the uncertainty in Y removed by knowing that X also occurred. Let X be the event the feature “Apple” occurs in a document, whereas Y be the event the feature “Steve Jobs” occurs in a document. If the document is about the Apple computers founded by Steve Jobs, then P(X, Y) denoting the joint probability distribution of X and Y, is greater than the product of the probabilities P(X)P(Y), because presence of the feature “Apple” would increase the chances of the feature “Steve Jobs” being present and vice-verse. Thus mutual information would be high in this case compared to if the document belonged to “Health benefits of fruits every day”. In terms of entropy, knowing that the feature “Apple” is present, makes the occurrence of the feature “Steve Jobs” much more certain than if “Apple” have not occurred and vice-verse. In the context of text classification, let X be the occurrence of the feature F in a document and Y be the event that a document belongs to class C. The point-wise mutual information, for document containing feature F and also belonging to class C.

PMI(F, C) = log (P(X=F, Y=C)/P(X=F)P(Y=C)),

Similarly the PMI for document containing feature F but not belonging to class C : PMI(F, C^{T}), document not containing feature F and belonging to class C : PMI(F^{T}, C) and document not containing feature F as well as not belonging to class C : PMI(F^{T}, C^{T}), where X=F^{T} denotes the event that document does not contain feature F and Y=C^{T} denotes the event that document does not belong to class C :

PMI(F, C^{T}) = log (P(X=F, Y=C^{T})/P(X=F)P(Y=C^{T})),

PMI(F^{T}, C) = log (P(X=F^{T}, Y=C)/P(X=F^{T})P(Y=C^{T})),

PMI(F^{T}, C^{T}) = log (P(X=F^{T}, Y=C^{T})/P(X=F^{T})P(Y=C^{T})),

Thus the expected mutual information for feature F and class C is given as :

MI(F, C) = P(X=F, Y=C) * PMI(F, C) + P(X=F, Y=C^{T}) * PMI(F, C^{T}) + P(X=F^{T}, Y=C) * PMI(F^{T}, C) + P(X=F^{T}, Y=C^{T}) * PMI(F^{T}, C^{T})

For multiple classes C_{i}, to check whether a feature F is discriminant or not, find the expected MI for feature F, using MI values of feature F with all the classes, i.e.

D(F) = ∑ P(C_{i}) * MI(F, C_{i}), where D(F) is the discrimination factor for feature F

From our earlier example with 1000 documents, 100 belong to c_{1}, 800 to c_{2} and 100 to c_{3}. Out of 1000 documents and 200 documents containing feature F, 30 belongs to class c_{1}, 120 to class c_{2} and remaining 50 to class c_{3}. Hence, for class c_{1},

PMI(F, c_{1}) = 0.58, PMI(F, c_{1}^{T}) = -0.083, PMI(F^{T}, c_{1}) = -0.19, PMI(F^{T}, c_{1}^{T}) = 0.02, Thus

MI(F, c_{1}) = 0.00459

PMI(F, c_{2}) = -0.41, PMI(F, c_{2}^{T}) = 1.0, PMI(F^{T}, c_{2}) = 0.087, PMI(F^{T}, c_{2}^{T}) = -0.41, Thus

MI(F, c_{2}) = 0.04076

PMI(F, c_{3}) = 1.32, PMI(F, c_{3}^{T}) = -0.26, PMI(F^{T}, c_{3}) = -0.67, PMI(F^{T}, c_{3}^{T}) = 0.06, Thus

MI(F, c_{3}) = 0.0385

Thus the discriminant factor D(F) for the feature F is : D(F) = 0.037. We see that the feature F is more informative to classes c_{2} and c_{3}, as compared to class c_{1}

Mutual information is minimum (maximum uncertainty) when the feature F is equally probable in all the 3 classes and hence the feature information is independent of the class information. Mutual information is 0 when the feature is equally probable in all the classes and also the classes are equally distributed across the set of documents.

Mutual information is maximum (minimum uncertainty) when the feature is present in any one of the classes and thus these features becomes discriminative. In this example the feature F is slightly discriminative as its value is greater than 0 but we cannot say that it is highly discriminative of any particular class.