When using support vector machine, are there any guidelines on choosing linear kernel vs. nonlinear kernel, like RBF? I once heard that non-linear kernel tends not to perform well once the number of features is large. Are there any references on this issue?
2 Answers
Usually, the decision is whether to use linear or an RBF (aka Gaussian) kernel. There are two main factors to consider:
- Solving the optimisation problem for a linear kernel is much faster, see e.g. LIBLINEAR.
- Typically, the best possible predictive performance is better for a nonlinear kernel (or at least as good as the linear one).
It's been shown that the linear kernel is a degenerate version of RBF, hence the linear kernel is never more accurate than a properly tuned RBF kernel. Quoting the abstract from the paper I linked:
The analysis also indicates that if complete model selection using the Gaussian kernel has been conducted, there is no need to consider linear SVM.
A basic rule of thumb is briefly covered in NTU's practical guide to support vector classification (Appendix C).
If the number of features is large, one may not need to map data to a higher dimensional space. That is, the nonlinear mapping does not improve the performance. Using the linear kernel is good enough, and one only searches for the parameter C.
Your conclusion is more or less right but you have the argument backwards. In practice, the linear kernel tends to perform very well when the number of features is large (e.g. there is no need to map to an even higher dimensional feature space). A typical example of this is document classification, with thousands of dimensions in input space.
In those cases, nonlinear kernels are not necessarily significantly more accurate than the linear one. This basically means nonlinear kernels lose their appeal: they require way more resources to train with little to no gain in predictive performance, so why bother.
TL;DR
Always try linear first since it is way faster to train (AND test). If the accuracy suffices, pat yourself on the back for a job well done and move on to the next problem. If not, try a nonlinear kernel.
-
1$\begingroup$ I have this explanation for the kernel trick: stats.stackexchange.com/questions/131138/… $\endgroup$– user83346Commented Aug 20, 2015 at 11:13
Andrew Ng gives a nice rule of thumb explanation in this video starting 14:46, though the whole video is worth watching.
Key Points
- Use linear kernel when number of features is larger than number of observations.
- Use gaussian kernel when number of observations is larger than number of features.
- If number of observations is larger than 50,000 speed could be an issue when using gaussian kernel; hence, one might want to use linear kernel.
-
-
2$\begingroup$ link is dead : I think that this is the same video : youtube.com/watch?v=hDh7jmEGoY0 $\endgroup$– ihebihebCommented Jun 15, 2018 at 15:50
-
$\begingroup$ @ihebiheb That link is also dead. Maybe this one: youtube.com/watch?v=8NYoQiRANpg $\endgroup$ Commented Nov 4, 2023 at 8:40