Error output from NLP - Course-1, week-3, w3_unittest.test_get_country(get_country)

Hi,

my w3_unittest.test_cosine_similarity(cosine_similarity) passed all tests. And I got the expected output for king & queen.
Output:
0.6510956647989061
Expected Output :
≈≈ 0.651095

But I am getting errors for this w3_unittest.test_get_country(get_country). All the similarities are wrong. How is that possible if the cosine similarity passed the tests?

Wrong output word.
Expected: Egypt.
Got: Tunis.
Wrong output similarity. Maybe you should check your cosine_similarity implementation.
Expected: 0.7626821.
Got: 0.5291996936511493.
Wrong output similarity. Maybe you should check your cosine_similarity implementation.
Expected: 0.5611889.
Got: 0.5177736483102966.
Wrong output word.
Expected: Indonesia.
Got: Bangkok.
Wrong output similarity. Maybe you should check your cosine_similarity implementation.
Expected: 0.6782036.
Got: 0.5991033866658644.

Thanks,
David

Did you notice that the Expected: is a country but the Got: is a city? Without even looking at the code I want to say the issue is not in cosine_similarity but related to city vs country in the generation of get_country. The comment from the grader is just a guess but maybe not a helpful one.

4 Likes

Thank you. I switched around the equation and it worked. Thanks!

1 Like