C1_W3_Assignment - Getting Tunisia as output of get_country

Used the local embeddings, checked cosine similarity, and does not seem to be wrong. Know somewhere going wrong, but really canot finger point. Tried manually outside cell, and really the cosine similarity for tunisia is the max.

Lab id tyqgvlpkiflo

The mentors do not have the superpower to look directly at anyone else’s notebooks based on the lab id. There must be some mistake in your code. There aren’t really that many moving parts here if all your previous functions pass their test cases.

Just as an experiment, I added the following to my logic in the loop over all the words:

 if word == "Egypt" or word == "Tunis" or word == "Tunisia":
        print(f"{word} = {cur_similarity} (current max value {similarity})")

When I run the test cell for my version of get_country, here’s what I see:

Egypt = 0.7626821994781494 (current max value 0.44078245759010315)
Tunisia = 0.6102943420410156 (current max value 0.7626821994781494) 
Tunis = 0.5451543927192688 (current max value 0.7626821994781494)

Out[23]:

('Egypt', 0.7626822)

What do you see if you try that experiment? Maybe that will shed some light. If that doesn’t help, then we’ll have to share the code. But we can’t do that on a public thread, so please check your DMs for a message from me about how to proceed.

Tunisia = 0.15471170842647552 (current max value 0.4379616379737854)
Tunis = 0.5291997194290161 (current max value 0.5291997194290161)

it has to be cosine similarity implementation, but that i am not sure whats happening

Yes, your values for Tunisia and Tunis differ from mine. Did your cosine_similarity pass the tests in the notebook?

Thanks for the DM and your response. Sent the file via DM

To close the loop on the public thread, the error was in the logic that implements this part of the computation:

King - Man + Woman = ???