Wrong results in Graded Assignment Week 1 -

mathematics-for-machine-learning-and-data-science/lesson/el645/naive-bayes

Week 1 assignment - Cell #16, How the the expected output be as shown - there is a mismatch on the test-data sent to the function:

test_output = get_word_frequency([[‘like’,‘going’,‘river’], [‘love’, ‘deep’, ‘river’], [‘hate’,‘river’]], [1,0,0])
print(test_output)

num_emails 3
{‘river’, ‘going’, ‘like’} 1
{‘deep’, ‘river’, ‘love’} 0
{‘hate’, ‘river’} 0
{‘river’: {‘spam’: 1, ‘ham’: 2}, ‘going’: {‘spam’: 1, ‘ham’: 0}, ‘like’: {‘spam’: 1, ‘ham’: 0}, ‘deep’: {‘spam’: 0, ‘ham’: 1}, ‘love’: {‘spam’: 0, ‘ham’: 1}, ‘hate’: {‘spam’: 0, ‘ham’: 1}}

Expected Output (the output order may vary, what is important is the values for each word)
{'going': {'spam': 2, 'ham': 1}, 'river': {'spam': 2, 'ham': 3}, 'like': {'spam': 2, 'ham': 1}, 'deep': {'spam': 1, 'ham': 2}, 'love': {'spam': 1, 'ham': 2}, 'hate': {'spam': 1, 'ham': 2}}

You have posted in the forum area for “Generative AI with Large Language Models”.
That’s not the course to which your question applies.

1 Like