I am getting wrong output for # UNQ_C8

I donot understand the mistake I am doing in the code c1 W4 assignment - # UNQ_C8. It would be great if I can get some help. When I run the test, I get wrong output. # UNQ_C8.

Hi @arunteja

Codes to recheck

You first create an empty similarity list

then for each candidate vector, you use for loop where candidates in row are recalled, under which you create a cosine similarity using row and v
under this you append the cos_similarity to the similarity list you created first.(YOUR ISSUES PROBABLY LIES HERE)

Next , this is outside of the for loop!!
You create sorted_ids using np.argsort of similarity list

next to reverse the order of sorted ids array, To reverse the order of the result of numpy.argsort to get the element with highest cosine similarity as the first element of the array you can use tmp[::-1]. This reverses the order of an array. Then, you can extract the first k elements.

Now you create k_idx using sorted_ids with [:k] (THIS COULD BE ANOTHER PLACE WHERE YOU RECALLED THE K PLACEMENT INCORRECTLY)

Can you confirm if you have followed the same codes.

Regards
DP