Even though I passed nearest_neighbor tests, and followed all the instructions of the exercise, i couldn’t get the expected output. instead, I keep getting the output 0.0.
check if you have mixed local variables with global variables
It sounds like there must be some misunderstanding in your code. If the suggestion about referencing global variables doesn’t help, then one other easy step to try would be to make sure your notebook is in a consistent state. Try this sequence and see if that changes the results:
Kernel -> Restart and Clear Output
Save
Cell -> Run All
If the test still fails with 0.0 as the success percentage, then we’ll probably need to look at your code. We can’t do that on a public thread, but please check your DMs for a message from me about how to proceed.
To close the loop on the public thread, it turns out that the code for test_vocabulary actually was correct, but the bug was an indexing problem in the previous function nearest_neighbor that gets called by test_vocabulary. But somehow that bug wasn’t caught by the unit tests for nearest_neighbor. So it was definitely not a straightforward issue to debug.
I’ll take a look at the test cases and see if I can suggest to the course staff a way to beef them up a bit. ![]()
It turns out that the tests were not very comprehensive here. I just filed a github request with some suggested additional tests that would check some important subcases, including catching the bug here. No guarantees that will be implemented anytime soon, but we’re trying anyway.
