Hi what am I missing in implementing naive_bayes function? I pass the test but I get zero in grade reason: division by zero
def naive_bayes(treated_email, word_frequency, class_frequency,
# mentor edit: code removed
Hi what am I missing in implementing naive_bayes function? I pass the test but I get zero in grade reason: division by zero
def naive_bayes(treated_email, word_frequency, class_frequency,
# mentor edit: code removed
Please do not post your code on the forum. That’s not allowed by the Code of Conduct.
If a mentor needs to see your code, we’ll contact you with instructions.
Hint:
p_spam and p_ham should do some math using the class_frequency - not by using prob_email…
thanks TMosh but my code passed the test and everything after. Why we created prob_email_given_class in first place?
That’s a good question. I do not have an answer.
There are many mysteries about the M4ML course design.
Hello @Hassan_Mohamed6
your codes are incorrect
while Compute P(email | spam) with the function you defined just above, kindly mention cls=‘spam’ in the code
Also to compute P(spam) and p(ham) using the class_frequency dictionary and using the formula #spam emails / #total emails, but you are not using class frequency
Compute the quantity P(spam) * P(email | spam), let’s call it spam_likelihood
while mentioning (email | spam) means email or spam but have included both.
Also I have doubt if you are working on a updated assignment notebook? as the course3 week 1 and week 4 assignments were updated. So kindly make sure you have an updated copy.
Regards
DP
Thanks Deepti will check and come back to you