Reputation: 1167
My application contain a learning task which is an SVM classification. After a hard research I understand the basics of SVM and I also tried some example with libSVM tool via command line. However, my application is deployed in client-server architecture :
My question is how to use libSVM in Java code instead of running it via command line?
Upvotes: 0
Views: 3315
Reputation: 3287
I found this project and it works well.
LIBSVM on Android platform with a native library for better performance
Upvotes: 1
Reputation: 938
you can use method contain this project for Android developments
LIBSVM for android jni environment
Upvotes: 1
Reputation: 12152
The most universal, multi-language way of doing this is to implement the equation to to get a decision score for a sample given the trained SVM. This will work in Java, C, Dalvik, Objective C, whatever you may use now or whenever in the future.
The model file LIBSVM generates has three important things:
Given a new point x, you compute
where everything is as explained above and K is the kernel you used to train.
and the decision is just the sign of this decision value (sgn(f(x)) for an example x)
Upvotes: 0
Reputation: 11941
Since the documentation is a bit scant, the best way is probably to have a look at the source of the command line tool svm_predict.java in the libsvm distribution.
e.g. to load an svm model from a file:
svm_model model = svm.svm_load_model("filename");
Then you can make a prediction:
double v = svm.svm_predict(model, x);
The predict()
method in svm_predict.java has the details of how to set up x.
Upvotes: 1