from sklearn.datasets import make_circles
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
import numpy as np, matplotlib.pyplot as mp
X, y = make_circles(noise=.1, factor=.4)
X = StandardScaler().fit_transform(X)
for e, kernel in enumerate(['linear', 'rbf'], 1):
clf = SVC(kernel=kernel)
clf.fit(X, y)
mp.subplot(1, 2, e)
mp.scatter(X[:, 0], X[:, 1], s=40, c=y)
x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
xx, yy = np.meshgrid(np.arange(x_min, x_max, .01), np.arange(y_min, y_max, .01))
Z = clf.decision_function(np.c_[xx.ravel(), yy.ravel()]).reshape(xx.shape)
mp.contourf(xx, yy, Z, 0, alpha=.2)
mp.show()
![sklearn支持向量机(待完成) sklearn支持向量机(待完成)](/default/index/img?u=aHR0cHM6Ly9waWFuc2hlbi5jb20vaW1hZ2VzLzU0L2Q3M2JiYmZkMTM1MThjNzg3Zjg0NWIxNjhhODVjZmJlLnBuZw==)