# Smoothing a 2-by-2 contingency table

I am trying to implement a system for automatic document categorization, where each document of a corpus belongs to some class. I define the following contingency table for every class C and every word W:

$\begin{array}{c|cc} & W & \bar{W}\\ \hline C & \frac{nb\_docs(C,W)}{nb\_docs} & \frac{nb\_docs(C,\bar{W})}{nb\_docs}\\ \bar{C} & \frac{nb\_docs(\bar{C},W)}{nb\_docs} & \frac{nb\_docs(\bar{C},\bar{W})}{nb\_docs}\\ \end{array}$

where $nb\_docs$ is the total number of documents in the corpus, $nb\_docs(C,W)$ is the number of documents of class C that contains the word $W$, $nb\_docs(C,\bar{W})$ is the number of documents of class C that does NOT contain $W$, and so on.

I need to smooth this table to avoid zero values, ideally something simple similarly to Laplace smoothing (i.e., add-one smoothing) while keeping well-defined probabilities/normalized frequencies.

I can't figure out how to do that... Any idea?

Edit: My goal is to extract the most "important" terms to reduce the dimensionality of the space during classification. There are many functions to identify those important terms, some being undefined with zero probabilities. Undefined values could be simply ignored but there should be some way to deal with this :)

• Why do you need to avoid zeros? – Glen_b -Reinstate Monica Sep 17 '12 at 23:21
• Question edited :) – DevelBD Sep 18 '12 at 10:15