I’m working on the Naive Bayes Programing assignment C3w1. I have got the get_word_frequency function working, however the output numbers are different from the expected output.
Should I assume something is wrong with my code? or could this be normal?
TMosh
March 8, 2024, 10:56pm
2
This means it (probably) isn’t working correctly.
But I’ll do a couple of tests and report back.
1 Like
TMosh
March 8, 2024, 11:56pm
3
Your results are not correct. The ham and spam counts are wrong for each of the words in the dictionary.
Thanks1 I was able to figure out where I was going wrong
1 Like
Hi Ian, I ran into the same problem.
How did you manage to solve it?
see if the below post comment helps you
Hello @NhomNhom
Review of your notebook
get_word_frequency
You have recalled number of emails with the wrong parameter, remember array of email is X and not Y(it is label corresponding to each email)
prob_word_given_class code are perfectly right, so no correction required.
for prob_email_given_class, the below code is incorrect
Update the prob by multiplying it with P(word | class).
Don’t forget to add the word_frequency and class_frequency parameters!
prob *= word_frequency[word]…
I’ll give it a go, thank you!