Search code examples
javamatlabsvmlibsvm

What is the best way to use a trained LibSVM model inside a Java application?


I have a trained LibSVM model which I want to use as a part of a Java application. I am thinking of two potentially possible ways for doing that.

  1. Extracting the classification decision formula, if it is possible, and re-implement them inside the Java application.

  2. I wonder if there is a Java library through which trained LibSVM models can be used. If there is not, I think such a library will be a good idea, no?

Any idea of how I can do this will be most appreciated.


Solution

  • Current LIBSVM package includes Java version (both JAR and source codes) directly. Please refer to the Interfaces and extensions to LIBSVM section in the LIBSVM Official website. Since it is maintained by LIBSVM authors at National Taiwan University, the version is latest so this should be the best package to use.

    Specifically, after downloading the latest version of LIBSVM Package (3.20) and extracting it, use libsvm-3.20/java/svm_predict.java to load your trained model and predict test instances.