J-SVMstruct

NOTE: This binding is not compatible with the latest version of SVM-struct.
This is a Java binding to the SVMstruct package for supervised learning with complex output spaces.
The package can be downloaded here. You will need to download SVMstruct as well.

Installation and Compilation of the Java Binding

The Java binding has been tested on Linux and on Windows (where Cygwin was used when compiling).

Get the package and decompress it. This will create a directory named jsvmstruct-x.xx, where x.xx is the current version number. Get SVMstruct, go to the subdirectory named jni, and decompress the SVMstruct package there.

Execute the following command:

patch -p1 < PATCH, where PATCH is jni_linux.patch or jni_cygwin.patch depending on your system.

Edit the Makefile to suit your system settings (the current Makefile is written for my Linux system). In particular, you may need to change the following line:

JAVA_DIR=/work/program/java (change this to where your Java distribution resides)

After editing the makefile, run make.

Running the example

The package includes a Java implementation of the multiclass problem. This example resides in the test subdirectory.

To compile the example, go to the test directory and invoke the compiler as follows:

javac -classpath ../jsvmstruct.jar Multiclass.java

Then, we can train a model:

java -Djava.library.path=../jni -cp ../jsvmstruct.jar:. jsvmstruct.JSVMStruct -learn Multiclass -c 1 train.txt mymodel

Finally, we can test the model:

java -Djava.library.path=../jni -cp ../jsvmstruct.jar:. jsvmstruct.JSVMStruct -predict Multiclass test.txt mymodel out.txt

On Unix systems, you might want to define the environment variables CLASSPATH and LD_LIBRARY_PATH to save you some typing.

References

The library is still not documented, but you can find the rudimentary Javadoc here.

Richard Johansson (richard.johanssonimage/pnggu.se)