简介

原理

Python实现

导包

1
from sklearn import svm

函数声明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 分类 classification
sklearn.svm.SVC(
C=1.0,
kernel='rbf',
degree=3,
gamma=0.0,
coef0=0.0,
shrinking=True,
probability=False,
tol=0.001,
cache_size=200,
class_weight=None,
verbose=False,
max_iter=-1,
random_state=None
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 回归 regression
sklearn.svm.SVR(
kernel ='rbf'
degree = 3
gamma ='auto_deprecated'
coef0 = 0.0
tol = 0.001
C = 1.0
epsilon = 0.1
shrinking = True
cache_size = 200
verbose = False
max_iter = -1
)

速度慢的问题

Sklearn GridSearchCV跑SVM很慢或卡死解决办法,SVM线性核函数卡死_svm训练时长大概多久-CSDN博客

Reference

  1. 支持向量机|博客园
  2. SVM简介及sklearn实现
  3. sklearn中SVM的实现