Arash m
Arash m

Reputation: 109

How to conduct a 'multi classification' approach with LibSVM?

I am beginner at LibSVM. I want to use one vs all strategy multiclassification by LibSVM. To do so, I've read its fundamental, but they does not make me an idea. Is there any good Java code example for this?

Upvotes: 0

Views: 774

Answers (1)

rzo1
rzo1

Reputation: 5751

According to the implementation documentation the library LIBSVM uses the "one vs all" strategy for multiclass prediction by default.

For code samples you can take a look on the Java port of LIBSVM, which can be found here for training and here for prediction.

Basically you can use the provided CLI to train/predict. If you like to use it in your own code, you have to perform some "refactoring" in order to make it more feasable for your purpose.

The basics steps to use it with java are:

  1. Provide a training file in "sparse" format as requested by the library. This is just "classLabel feature_id1:feature_value1 feature_id2:feature_value2 ...". The class label and the feature_id's must be integers.
  2. After you obtain the training file, you can use the CLI tools as described on their website (you just have to configure the kernel specific parameters). In your case, the library will automatically detect more than 2 classes and therefore it will start to train a multiclass SVM using "one vs all".
  3. Repeat 1.) to obtain your test file and go ahead for the CLI tools in order to evaluate your model.

Upvotes: 2

Related Questions