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

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…

Contents