I fixed a lot of things in this edit. I made it much more general than the first versions, so the functions can work with different data sets. I also created an accuracy function that tests how many classifications that algorithm gets correct. For k=3 the accuracy is .98. For k=7, the accuracy is .967. That algorithm takes about 10 seconds to run though, so I will need to speed it up some how. Maybe use less for-loops.