C1_W2_Assignment_Exercise 2 - train_naive_bayes

I added several print statements to instrument my train_naive_bayes function and here’s what I see when I run that test cell:

type(wordlist) <class 'list'>
V = 9165, len(wordlist) 11436
V: 9165, V_pos: 5804, V_neg: 5632, D: 8000, D_pos: 4000, D_neg: 4000, N_pos: 27547, N_neg: 27152
freq_pos for smile = 47
freq_neg for smile = 9
loglikelihood for smile = 1.5577981920239676
0.0
9165

The most common error on this function is simply to add one to N_pos and N_neg for each occurrence. The intent here is that you add the actual frequency each time by looking it up in the freqs dictionary that was passed in as an argument.

Of course there are other moving parts here, e.g. check the order of operations on your computation of p_w_pos and p_w_neg.