如何在我的 Java 代码中将 LibSVM 与 Weka 结合使用?
我想在我的应用程序中将 LibSVM 分类器与 Weka 一起使用。我该如何(或者在哪里可以找到好的例子)做到这一点?
I want to use LibSVM classifier with Weka in my application. How can I (or where can I find good examples to) do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
请点击此链接以结合 Weka 和 libsvm
http://www.cs.iastate.edu/~yasser/wlsvm/
weka 擅长计算 ROC、召回率等......
libsvm 适用于分类、回归等...
follow this link for combining Weka and libsvm
http://www.cs.iastate.edu/~yasser/wlsvm/
weka is good calculating ROC,recall,etc....
and libsvm is good for classification, regression,etc...
当然现在有点晚了,但无论如何我都会回答。您必须在项目中使用 weka.jar、libsvm.jar 和 wlsvm.jar(libsvm 包装器)。因此,只需将所有 3 个 jar 包含在您的构建路径或类路径或其他路径中即可。
您可以从此处获取 wlsvm.jar:http://ailab.ist.psu。 edu/yasser/wlsvm.html
您可以从这里获取 weka:http ://www.cs.waikato.ac.nz/ml/weka/
你可以从这里获取libsvm:http://www.csie.ntu.edu.tw/~cjlin/libsvm/
我无法让它与 weka 3.7.7 或 3.7.8 一起使用,但我能够让它与 3.6.8(今天最新的稳定版本)一起工作。
另外,因为我必须从 svnlib 获取 .class 文件,并将这些文件包含在我的项目的构建路径中。要构建 .class 文件,请使用 SVNLib/java 中的 make 文件。
这里有一小段代码可以帮助您入门:
祝您好运。
A little late now, surely, but I'll answer anyways. You have to use weka.jar, libsvm.jar, and wlsvm.jar (the libsvm wrapper) in your project. So just include all 3 jars in your build path or class path or whatever.
You can get the wlsvm.jar from here: http://ailab.ist.psu.edu/yasser/wlsvm.html
You can get weka from here: http://www.cs.waikato.ac.nz/ml/weka/
And you can get libsvm from here: http://www.csie.ntu.edu.tw/~cjlin/libsvm/
I could not get this to work with weka 3.7.7 or 3.7.8, but I was able to get it working with 3.6.8 (latest stable version as of today).
Also, as I had to get the .class files from the svnlib and also include those in the build path to my project. To build the .class files, use the make file in the SVNLib/java.
Here is a small piece of code to get you started:
Good luck.
在新版本中,您只需要 weka.jar 并像这样调用 svm,
如果您喜欢提供选项,请像这样设置选项
最后训练分类器
With new version you just need the weka.jar and call svm like this,
If you prefer to give options set the options like this
Finally train the classifier
要在最新版本的 weka (3.7.9) 中使用 libSVM 库,您只需使用 weka 应用程序的“包管理器”并安装 libSVM 包。
最后,在 java 项目中,您必须将“包管理器”创建的 LibSVM 库添加到类路径中。
通常它位于“(HOME)\wekafiles\packages\LibSVM”目录中。
To use the libSVM library with the newest version of weka (3.7.9), you only need to use the "Package Manager" of the weka application and install the libSVM package.
Finally from the java project, you have to add the LibSVM library that was created by the "Package Manager" to the Classpath.
Usually it's in the "(HOME)\wekafiles\packages\LibSVM" directory.
事实证明,weka 人员通过从 Maven Central 提供最新版本的内容,使我们的工作变得更加轻松。
只需从这里获取依赖项:
http://mvnrepository.com/artifact/nz.ac.waikato.cms .weka/LibSVM
,只要有依赖关系,一切都会正常工作。不要乱搞包装器并向类路径添加 jar 或类似的东西。
我使用的是 3.7.12 版本,但我认为自从包管理器功能添加到 GUI 以来它就可用了。
Turns out the weka guys have made our job a LOT easier with the most recent versions by making things available from Maven Central.
Simply get the dependency from here:
http://mvnrepository.com/artifact/nz.ac.waikato.cms.weka/LibSVM
and everything will work as far as dependencies go. No messing around with wrappers and adding jars to the classpath or anything like that.
I'm using version 3.7.12 but I assume it's been available since the package manager function was added to the GUI.