sklearn中的支持向量机
一,概览
二,SVC讲解
class sklearn.svm.SVC(*, C=1.0, kernel='rbf', degree=3, gamma='scale', coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape='ovr', break_ties=False, random_state=None)1,线性SVM决策过程可视化
# encoding=utf-8from sklearn.datasets import make_blobsfrom sklearn.svm import SVCimport matplotlib.pyplot as pltimport numpy as npX, y = make_blobs(n_samples=50, centers=2, random_state=0, cluster_std=0.6)ax = plt.gca() # 获取当前的子图,如果不存在,则创建新的子图# 将上述过程包装成函数:def plot_svc_decision_function(model, ax=None): if ax is None: ax = plt.gca() xlim = ax.get_xlim() ylim = ax.get_ylim() x = np.linspace(xlim[0], xlim[1], 30) y = np.linspace(ylim[0], ylim[1], 30) Y, X = np.meshgrid(y, x) xy = n