Help in the lab from Week1, part 4, exercise 2

Hello everyone, I have been trying to get through this lab for a very long time but I still don´t know what is my error, could you help me please? Is from the week-1 C3W1_Assignment

I got the correct output of the exercise 1 but in the exercise 2 I got this error, when trying to solve this:

“Implement the function to compute 𝑃(word∣spam)𝑃(word∣spam) and 𝑃(word∣ham)”
I got this error message:
----> 1 print(f"P(lottery | spam) = {prob_word_given_class(‘lottery’, cls = ‘spam’, word_frequency = word_frequency, class_frequency = class_frequency)}")

I suspect the values I included in this part are not correct:

Get the amount of times the word appears with the given class (class is stores in spam variable)

amount_word_and_class = word_frequency[word]['spam']
p_word_given_class = amount_word_and_class/[cls]['spam']

I also got this error message underlined
p_word_given_class = amount_word_and_class/[cls][‘spam’]

Please post a screen capture image that shows the error messages or asserts.

Using text copy-and-paste usually doesn’t have enough context.

well here are the screenshots, thank you so much for viewing my post

There are two issues that are causing errors:

  1. ‘spam’ is not the correct value to use there. It’s the cls parameter.

  2. The divisor should be the class_frequency of the cls parameter.