How to get the nearest neighbor in weka using java
Asked Answered
W

1

9

I've been trying to use the Ibk nearest neighbor algorithm that goes together with the weka machine learning library.

I know how to classify instances, but I want to implement the collaborative filtering feature so I need to actually get the list of actual objects that are nearest to the object of interest.

How would I actually do so in weka using its java API?

Walterwalters answered 2/7, 2011 at 2:43 Comment(1)
Hey there mate I know this is old post but Im trying to implement this for my tesis, and I can't really figure out or understand how to do all this, I was wondering if you could share how can I make the instances and what are them? or share me a link to understand this better, like in my case the data im going to recommend are dishes depending on dishes each user has picked before. But I don't know if each instance is a dish or what? anyways if you could share how to classify instances and what are they its appreciatedGuenon
L
11

How about this one

weka.core.neighboursearch.LinearNNSearch knn = new LinearNNSearch(
            trainingInstances);
//do other stuff

Instances nearestInstances= knn.kNearestNeighbours(target, 3)

Here is the API documentation that you can refer to.

Loveland answered 4/7, 2011 at 22:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.