# import svm from sklearn
from sklearn import svm
# 创建训练集
X = [[0, 0], [1, 1]]
Y = [0, 1]
# 创建SVC分类器
clf = svm.SVC(kernel = 'linear')
# 对训练数据进行拟合
clf.fit(X, Y)
# 进行预测, 输出结果
print(clf.predict([[2, 2]]))
run it
➜ test ✗ python3 svm.py
[1]
Keep Learning
# import svm from sklearn
from sklearn import svm
# 创建训练集
X = [[0, 0], [1, 1]]
Y = [0, 1]
# 创建SVC分类器
clf = svm.SVC(kernel = 'linear')
# 对训练数据进行拟合
clf.fit(X, Y)
# 进行预测, 输出结果
print(clf.predict([[2, 2]]))
run it
➜ test ✗ python3 svm.py
[1]
Be First to Comment