Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from sklearn import svm
#X-> training inputs
#Y-> training outputs
# Here we are training a binary classifier
X = [[1, 0, 2], [0, 1, 3]]
y = [0, 1]
##SVM with setting kernel='linear'
##By default we all have kernel='RBF'
clf = svm.SVC(kernel='linear', C=1), y)
SVC(C=1, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape=None, degree=3, gamma='auto', kernel='linear',
max_iter=-1, probability=False, random_state=None, shrinking=True,
tol=0.001, verbose=False)
clf.predict([[2., 2., 2.]])
HereLinearSVChas no parameter kernel as by default it is linear.
In [8]:
lin_clf = svm.LinearSVC(kernel='linear', C=1)
TypeError Traceback (most recent call last)
<ipython-input-8-08a26ddf4f5d> in <module>()
----> 1 lin_clf = svm.LinearSVC(kernel='linear', C=1)
TypeError: __init__() got an unexpected keyword argument 'kernel'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.