随手做一个笔记了算是:
Question:
- what’s different between SVC and LinearSVC in python sklearn library?
- Does the
SVC(kernel='linear')
have the same result onLinearSVC()
- if we want to model the linear kernel how do we choose?
Reply:
-
What is the difference between SVC and SVM in scikit-learn?
The SVM module (SVC, NuSVC, etc) is a wrapper around the libsvm library and supports different kernels whileLinearSVC
is based on liblinear and only supports a linear kernel. -
Under what parameters are SVC and LinearSVC in scikit-learn equivalent?
Personally I consider LinearSVC one of the mistakes of sklearn developers - this class is simply not a linear SVM.
To sum up: LinearSVC is not linear SVM, do not use it if do not have to. -
When should one use LinearSVC or SVC?
BetweenSVC
andLinearSVC
, one important decision criterion is thatLinearSVC
tends to be faster to converge the larger the number of samples is. This is due to the fact that the linear kernel is a special case, which is optimized for in Liblinear, but not in Libsvm. -
From documentation, you can also see the theory and math:
https://scikit-learn.org/stable/modules/svm.html#svc