C1_W4_Assignment - Exercise 6 Test Vocabulary

I’m completing the final assignment but seem to have some strange issue on Exercise 6.

In cell “UNQ_C11”, when running test_vocabulary I get an accuracy of 0, not the expected 0.557.

However, my code for all the other exercises has produced the expected output:

  • R_Train has been obtained through training, with the loss descent up to iteration 375 showing as expected.
  • nearest_neighbor function produces the expected output
  • get_matrices function produces the

Also, the unit tests pass for test_vocabulary (even though the cell above produces the wrong result).

I’ve also added some debug steps in my test_vocabulary and the predictions do appear to all be wrong.

Any ideas on how to further investigate? I am at a loss as to what’s gone wrong and where.

Could you share screenshots of your debug steps?

or DM the code screenshots of
def test_vocabulary(X, Y, R, nearest_neighbor=nearest_neighbor):
via personal DM. Click on my name and then message.

Points you need to follow

  1. Check if prediction where recalled using numpy dot for x times r
  2. If you initialised number correct to zero
  3. if the loop through each row was recalled correctly as the index of the nearest neighbour of pred should include row[i]
    4.under same loop check if index of nearest neighbour of pred is absolute equal to row i, then increment number correct by 1
  4. check if accuracy is number correct divided number of row in pred, i.e. len(pred)


1 Like

Thanks Deepti, was working on it late, but looking at it with fresh eyes this morning it was a super obvious mistake - and your list of points helped me spot it quickly. I’d written X instead of pred in the parameters for the nearest_neighbour :man_facepalming: