2-k-nearest-neighbors fixes

2-k-nearest-neighbors was bombing in the browser and in tests. This pull request contains fixes for these issues.

Disappointingly, even after these fixes, this example incorrectly predicts that I don't have a beard and glasses (I have both, and they're quite noticeable.) Not sure if this is due to an error in the code, or a limitation of the test data.