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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
K-nearest neighbor basics7m 35s
-
(Locked)
Loading flower data6m 45s
-
(Locked)
Creating a DataItem interface4m 56s
-
(Locked)
Calculating the closest data points4m 22s
-
(Locked)
Implementing the DataItem interface2m 13s
-
(Locked)
Letting your data points vote4m 19s
-
(Locked)
Finishing your KNN classifier3m 31s
-
-