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.
Implementing the DataItem interface - Java Tutorial
From the course: Data Science for Java Developers
Implementing the DataItem interface
- [Instructor] So let's go back here and make that the case. So we're going to add FlowerRecord implements DataItem to the top here. And it's going to ask us here to implement the methods, which we're going to do. We're going to have to implement getCoordinates and getClassifier. So for getCoordinates, we're going to say return arrays dot as list. And we're going to put in this dot sepal length, this dot sepal width... This dot petal length, and this dot petal width. And for getClassifier, we're simply going to return this dot species. So now if we go back to KNN example, we'll see that that got rid of the compiler error. So now that we've added all our data points to our classifier, let's say classifier dot classifyPoint. And for this, we'll say new FlowerRecord, and we'll just input some fairly random numbers since we're not using those yet anyway. And for the species, we can just add whatever we want since we're not…
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
-
-