From the course: Data Science for Java Developers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Letting your data points vote

Letting your data points vote - Java Tutorial

From the course: Data Science for Java Developers

Letting your data points vote

- [Instructor] Okay so we've decided what we need to do now is we need to somehow label each of these distances with its corresponding class label. Well, a good way to do this, that I've found anyway, is to use something called a pair. So now, instead of returning a list of doubles we're going to return a list of pairs with a string which is going to be the class label for each distance and the double which is going to be the actual distance itself. All right? So now we're just going to map each point instead of just mapping it to a distance we're going to map it to a new pair with the class label which you can get by saying point dot get classifier and the actual distance as the second part of the pair and then in order to sort it, we're going to say D1 dot get value dot compare to D2 dot get value. Okay so now, if we try running our program again to see what that does, we should see that now we…

Contents