improved kNN algorithm
fix some bugs in data processing