I do not understand what you mean. the Public test cell is:
PUBLIC TEST
def complete_analogy_test(target):
a = [3, 3] # Center at a
a_nw = [2, 4] # North-West oriented vector from a
a_s = [3, 2] # South oriented vector from a
c = [-2, 1] # Center at c
# Create a controlled word to vec map
word_to_vec_map = {'a': a,
'synonym_of_a': a,
'a_nw': a_nw,
'a_s': a_s,
'c': c,
'c_n': [-2, 2], # N
'c_ne': [-1, 2], # NE
'c_e': [-1, 1], # E
'c_se': [-1, 0], # SE
'c_s': [-2, 0], # S
'c_sw': [-3, 0], # SW
'c_w': [-3, 1], # W
'c_nw': [-3, 2] # NW
}
both “c_se” and “c_s” are defined.
What do you mean with “unexpected” and “not present” ?
There must be something different in how you wrote the code, because you picked a different “best analogy” for one of the word combinations. You picked another vector that points in the same direction, but is shorter. So how could that happen? There must be some subtle difference in your code. E.g. maybe you used >= instead of > for the comparison of the new value to the existing max?
Or maybe you removed this code that was given to you in the template for cosine_similarity:
# Special case. Consider the case u = [0, 0], v=[0, 0]
if np.all(u == v):
return 1
I instrumented my code for complete_analogy and here’s my output from the test:
input c best analog c_nw similarity 1
input c best analog c_s similarity 1
input c best analog a similarity 0
input a best analog c similarity 1
All tests passed
Go back and examine the code for cosine_similarity and ask yourself: how can the return value end up as an integer value? There’s no way that will happen if you go through the actual computations involving norms, right?