1.4 Finding the Country of each Capital - I am not getting the exact answer. And I cannot pass the assignment

  • Week # C1_W3_Assignment

1.4 Finding the Country of each Capital

Exercise 3 - get_country

Testing your function, note to make it more robust you can return the 5 most similar words.
get_country(‘Athens’, ‘Greece’, ‘Cairo’, word_embeddings)

Out[12]:
(‘Egypt’, 0.7626822)

Expected Output: (Approximately)
(‘Egypt’, 0.7626821)

And I am getting 0/10 in grading. Yesterday, I reported this under the issues in the assignment. But still I did not get an answer. Can someone help me to solve this?

image

Thank you

Hi @Anjanakg

Make sure you use correct parameters because this is the most common mistake when tests pass but grading fails.
For example, for get_country, make sure that you use embeddings instead of word_embeddings.

Cheers

Thank you for the reply. But I have no function “embeddings”. It is “word_embeddings”.

On the contrary, this is exactly your mistake:

You use variable named word_embeddings which is defined outside of the function.

Instead you should have used embeddings - the local variable (note the function parameters at the top).

Cheers

P.S. please remove your solution code, since it’s against the rules.

I am sorry, I cannot understand. “word_embeddings” is not a variable.

If it is possible, I can share my code.

Do not change the code outside the## START CODE HERE ### … and ### END CODE HERE ###.

Your mistake is in the function you implemented. (not in the cell below that you posted)

For example, you used word_embeddings[word] in your functions instead of embeddings[word]

And yes, both word_embeddings and embeddings are variables. Note the docstring of the function:

embeddings: a dictionary where the keys are words and values are their emmbeddings

An embeddings variable is a Python dictionary.

Cheers

Thank you. But still the last digit of my answer is showing as “2”

Well, my assignment is passed. Thank you so much! :grinning: I am sorry for bothering you.

1 Like