From the documentation scikit-learn implements SVC, NuSVC and LinearSVC which are classes capable of performing multi-class classification on a dataset. By the other hand I also read about that scikit learn also uses libsvm for support vector machine algorithm. I'm a bit confused about what's the difference between SVC and libsvm versions, by now I guess the difference is that SVC is the support vector machine algorithm fot the multiclass problem and libsvm is for the binary class problem. Could anybody help me to understad the difference between this?.
Asked
Active
Viewed 7.5k times
36
-
2Also see the docstring: http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC SVC is just a thin wrapper around libsvm. – Andreas Mueller Jan 14 '15 at 00:16
2 Answers
40
They are just different implementations of the same algorithm. The SVM module (SVC, NuSVC, etc) is a wrapper around the libsvm library and supports different kernels while LinearSVC
is based on liblinear and only supports a linear kernel. So:
SVC(kernel = 'linear')
is in theory "equivalent" to:
LinearSVC()
Because the implementations are different in practice you will get different results, the most important ones being that LinearSVC only supports a linear kernel, is faster and can scale a lot better.

elyase
- 39,479
- 12
- 112
- 119
-
21They are actually not equivalent as SVC uses a one-vs-one strategy while LinearSVC uses a one-vs-rest strategy for multi-class. Also LinearSVC defaults to L2 loss aka squared hinge loss. – Andreas Mueller Jan 14 '15 at 00:15
-
2Andreas is right pointing out that they are not they same. When I said "equivalent" I meant "similar" or "corresponds to", sorry for my bad English. Different implementations means differing defaults and many other details. – elyase Jan 14 '15 at 08:52
-
1For multi-class classification what aproach do you guys recommend me (one vs one or one vs rest), do you think I can attack this problem nicely with SVC?. – tumbleweed Jan 16 '15 at 06:47
-
9actually **LinearSVC is not SVM at all**, see http://stackoverflow.com/questions/33843981/under-what-parameters-are-svc-and-linearsvc-in-scikit-learn-equivalent – lejlot Nov 21 '15 at 14:56
3
This is a snapshot from the book Hands-on Machine Learning

desertnaut
- 57,590
- 26
- 140
- 166

nickz
- 55
- 8