Added brian.md to 04-ML_KNN

Thanks for all the comments, Aaron!

The way I thought that this would work -- and this was before Kevin had sent his email encouraging us to create a voting function for choosing the nearest neighbor when k > 1 -- was to sample one outcome from from the multiple nearest neighbors. The idea being that each nearest neighbor is just as valid as any other. It sounds lazy, but at the time it seemed statistically valid. But that was Friday. And a lot of things seem statistically valid on a Friday.


On Monday, August 4, 2014 4:24 PM, Aaron Schumacher <notifications@github.com> wrote:
 


In 04-ML_KNN/brian.R:
> @@ -0,0 +1,23 @@
> +assign.score <- function(test.row, labels, training.data, K = 1) {
> +  training.data$score <- apply(training.data[,1:4], 1, function(x) { sqrt((x[1] - test.row[1])^2 + (x[2] - test.row[2])^2 + (x[3] - test.row[3])^2 + (x[4] - test.row[4])^2)})
> +  sorted <- training.data[with(training.data, order(score)), ]
> +  return(sample(sorted[K, as.character(labels)], 1)) 
This line is a little peculiar; maybe I should try running the code to see better - but what do you expect it to do?
—
Reply to this email directly or view it on GitHub.