I found sklearn.svm.LinearSVC
and sklearn.svm.SVC(kernel='linear')
and they seem very similar to me, but I get very different results on Reuters.
sklearn.svm.LinearSVC: 81.05% in 28.87s train / 9.71s test
sklearn.svm.SVC : 33.55% in 6536.53s train / 2418.62s test
Both have a linear kernel. The tolerance of the LinearSVC is higher than the one of SVC:
LinearSVC(C=1.0, tol=0.0001, max_iter=1000, penalty='l2', loss='squared_hinge', dual=True, multi_class='ovr', fit_intercept=True, intercept_scaling=1)
SVC (C=1.0, tol=0.001, max_iter=-1, shrinking=True, probability=False, cache_size=200, decision_function_shape=None)
How do both functions differ otherwise? Even if I set kernel='linear
, tol=0.0001
, max_iter=1000 and
decision_function_shape='ovr'the
SVCtakes much longer than
LinearSVC`. Why?
I use sklearn 0.18
and both are wrapped in the OneVsRestClassifier
. I'm not sure if this makes the same as multi_class='ovr'
/ decision_function_shape='ovr'
.
sklearn
documentation contains the examples of fitting these classifiers. The results differ due to approaches that the models use.