When I run the testcases for UNQ_C21, I kept getting failed with this message:
Wrong chosen neighbor ids.
Expected: [8413, 2085, 4802, 5526].
Got: [8413, 3614, 4934, 5526].
So, for debugging, I added this testing code at the end of approximate_knn:
# My own Test
print("Cosine_similarity of the chosen vectors")
for id in nearest_neighbor_idx_l:
print(ids_to_consider_l[id], cosine_similarity(v, vecs_to_consider_arr[id]))
print("Cosine_similarity of the expected vectors")
Expect = [8413, 2085, 4802, 5526]
idx_l = [idx for idx in range(len(ids_to_consider_l)) if ids_to_consider_l[idx] in Expect]
for id in idx_l:
print(ids_to_consider_l[id], cosine_similarity(v, vecs_to_consider_arr[id]))
And I got:
Cosine_similarity of the chosen vectors
8413 0.9999999999999996
3614 0.9999999999999996
4934 0.9999999999999996
5526 0.9999999999999996
Cosine_similarity of the expected vectors
2085 0.10372946727000373
4802 0.5021306764187731
5526 0.9999999999999996
8413 0.9999999999999996
Obviously, 2085 and 4802 are far less similar than 4934 and 3614. Is there anything wrong with my test code? Or did I misunderstand anything? Or the expected answer is wrong?