learn sklearn(三) SVM

SVM : 支持向量机

sklearn 中支持向量机函数主要有两类函数:

  • 回归:SVC,NuSVC,LinearSVC
  • 分类:SVR,NuSVR,LinearSVR

以SVC原型说明:

1
class sklearn.svm.SVC(C=1.0, kernel='rbf', degree=3, gamma='auto', 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', random_state=None)

C:代表SVM中经验项的重要性,在正则项与经验项中权衡。C越大,越可能过拟合,C越小,越可能欠拟合。

kernel:代表使用的核函数。常用的有:linear,rbf(高斯核),poly,sigmoid,自定义函数。

class_weight:数组形式,将第i个class的类的C替换为C * class_weight[i],提高某个类别的重要性。

sample_weight:类似class_weight,提升某个样本的重要性。
class_weightsample_weight用来解决不平衡问题。

decision_function_shape:ovrovo用来解决多分类问题。

参考