I want to use LibSVM classifier with Weka in my application. How can I (or where can I find good examples to) do this?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
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.
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...
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.
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.
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