python实现简单的SVM

# -*- coding: utf-8 -*-
from sklearn.svm import SVC
import numpy as np
print(X.shape,Y.shape)
X = np.random.random((10,5)) #训练数据
Y = np.array([1,0,1,0,1,0,1,0,1,0]) #训练标签
T = np.random.random((20,5)) #预测数据
print(X.shape,Y.shape)
svc=SVC(kernel='poly',degree=3,gamma=1,coef0=0) #注意函数参数说明
svc.fit(X,Y)
pre=svc.predict(T)
print(X.shape,Y.shape)
print(pre)

  

猜你喜欢

转载自www.cnblogs.com/niulang/p/12125229.html