C3_W1_Assignement Exercise 10

Hello, you all.

I need a little help with Exercise 10. Maybe I am wrong on my formula for likelihood_word_given_spam, and likelihood_word_given_ham. I thought it would be the cumulative product of spam (respectively ham) times the probability of spam (respectively ham). I think I got it wrong.

Could anyone help me?

Thanks in advance for your help.

Try the class frequency of spam.

Thank you for your reply. I tried what you suggested, but I did not pass the test for exercise 10. Maybe I got something wrong somewhere else then. Here is my code for this part.

{moderator edit: code removed}

For cumulative product, I think it is correct since I am computing the probability of a word given it is a spam (resp ham)…

That’s not correct. “text” was already used to create the “words” list.

    # This is a list containing the words of the email 
    words = set(text.split())

Thank you, I see it now.