如何使用java获取weka中最近的邻居 [英] How to get the nearest neighbor in weka using java

查看:185
本文介绍了如何使用java获取weka中最近的邻居的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用与weka机器学习库一起使用的Ibk最近邻算法。

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.

我将如何在weka中实际执行此操作它的Java API?

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

推荐答案

这个怎么样

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

Instances nearestInstances= knn.kNearestNeighbours(target, 3)

以下是 API文档你可以参考。

这篇关于如何使用java获取weka中最近的邻居的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆