simple 1NN

I'm confused here as i'm unable to figure out why code is not working as expected on entire test data set. Same code works when I use it to predict value of 1 test data. 
Are you sure you're passing the data you want to pass? I would examine this to make sure (I'm not sure).