Hi everyone,

I am working on the last problem and I am running into some errors with my output. I’m getting fairly close where it is always one output that is off. I suspect it is the last line that is off. This is what I have:

prior_spam = class_freq[“spam”]/(class_freq[“spam”]+class_freq[“ham”])

prior_ham = class_freq[“ham”]/(class_freq[“spam”]+class_freq[“ham”])

prob_spam = (likelihood_word_given_spam*prior_spam)/(likelihood_word_given_ham*prior_ham+likelihood_word_given_spam*prior_spam)

Can someone tell me if this is right? I’m going off of the bayes’ theorem formula.

Screen Shot 2023-07-06 at 7.15.09 PM|690x204

Can someone respond to this?

I’m also stuck on this one.

Hi Stella, I personally did not need to create the `prior_spam`

and `prior_ham`

objects in order to pass this exercise. Perhaps a simpler approach where the `class_freq`

variable is mentioned only once per class is better suited.

Would you mind elaborating further on what you need help with?

Hi Tom, thank you for getting back to me! I am not sure what you mean by mentioning class_freq once per class. Could you give me an example?

Hi Stella, what I meant was that I only use these variables `class_freq['spam']`

and `class_freq['ham']`

once. I hope it’ll help to start from blank for this exercise.

I see! I think I figured it out. Thank you!

1 Like