What is the difference between Linear SVM and SVM with linear kernel?

I'm wondering whether there is a difference between Linear SVM and SVM with a linear kernel. Or is a linear SVM just a SVM with a linear kernel?

If so, what is the difference between the two variables linear_svm and linear_kernel in the following code.

from sklearn import svm
linear_svm = svm.LinearSVC(C=1).fit(X_train, y_train)
linear_kernel_svm=svm.SVC(kernel='linear', C=1).fit(X_train, y_train)

Topic scikit-learn svm python libsvm

Category Data Science


As you can read in the documentation (http://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVC.html) it's conceptually similar, but implemented in another way to add flexibility:

Similar to SVC with parameter kernel=’linear’, but implemented in terms of liblinear rather than libsvm, so it has more flexibility in the choice of penalties and loss functions and should scale better to large numbers of samples.

So if you only want to use linear support vectors use this one because it scales better and you get more freedom with your loss functions, but if you want to more easily try different kernels in a grid search use the more generic one.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.