4
votes

I am new to using the LIBSVM package. I am aware that tuning of parameters is important but I have a few questions.

How to choose the correct kernel? I know linear is fastest, but when should we use another one? Only if the accuracy is too low or is there some other way to program automatic selection of the correct kernel?

Secondly, is there an efficient way to tune SVM in matlab? Only thing I can think of is to make nested for-loops for each parameter I want to test, then train and predict with a classifier. That's a lot of code for something so basic ...

2

2 Answers

2
votes

How to choose the correct kernel? I know linear is fastest, but when should we use another one? Only if the accuracy is too low or is there some other way to program automatic selection of the correct kernel?

The best approach is always to start with a linear kernel. If you are dealing with large data sets (hundreds of thousands of instances in thousands of dimensions) you will probably want to use specialized linear packages (e.g. LIBLINEAR) or ensemble methods (EnsembleSVM). Note that the latter does not have a proper interface yet.

If you have high-dimensional sparse data, the linear kernel will usually perform very well, even in comparison with more complex kernels.

In general, if your accuracy with a linear kernel does not suffice, the best option is to use an RBF kernel. They are known to perform very well on most data sets. You will need to tune the kernel parameter gamma when you switch to RBF kernels, though.

Secondly, is there an efficient way to tune SVM in matlab?

Yes! LIBSVM provides k-fold cross-validation using the -v k flag during training. When you provide this option, the training will yield cross-validated accuracy (classification) or mse (regression) instead of a model. You will still need to loop over the parameter tuples, though.

0
votes

Check the below given link. Nice code snippets, especially showing the tuning of parameters using cross-validations using three different scales. Hope that helps !

https://sites.google.com/site/kittipat/libsvm_matlab/demo_libsvm_crossvalidation