We start by calculating the probability of observing a given word for a given category of documents (here, departments):
\[\hat{\mu}_{j,k} = \frac{W^*_{j,k} + \alpha_j}{n_k + \sum_{j=1}^J \alpha_{j}}\]
- \(W^*_{j,k}\) is the number of times feature \(j\) appears in documents in category \(k\)
- \(n_k\) is the total number of tokens in documents in category \(k\)
- \(\alpha_j\) is a “regularization” parameter, which shrinks differences in very common words towards 0
Next, we take the ratio of the log-odds for category \(k\) and \(k'\):
\[\text{log-odds-ratio}_{j,k} = log\left( \frac{\hat{\mu}_{j,k}}{1-\hat{\mu}_{j,k}}\right) - log\left( \frac{\hat{\mu}_{j,k'}}{1-\hat{\mu}_{j,k'}}\right) \]
Intuitively, this ratio estimates the relative probability of the use of word \(j\) between the two groups. When this ratio is positive, group \(k\) uses the word more often. When it is negative, group \(k'\) uses it more often.
Finally, we standardize the ratio by its variance (which downweights differences about which we are uncertain):
\[\text{Fightin' Words Score}_j = \frac{\text{log-odds-ratio}_{j,k}}{\sqrt{Var(\text{log-odds-ratio}_{j,k})}}\]