Skip to content

Instantly share code, notes, and snippets.

@Teaonly
Last active August 29, 2015 14:01
Show Gist options
  • Save Teaonly/38cd211cd856c719bd91 to your computer and use it in GitHub Desktop.
Save Teaonly/38cd211cd856c719bd91 to your computer and use it in GitHub Desktop.
关于libSVM 最基本使用
最简单使用libSVM,只需要指定2个参数,即C和RBF核函数的Sigma,训练命令行如下:
./svm-train -s 0 -c 0.5 -g 0.1 test test.model
生成模型文件,支持向量的第一项为 y(i)*alpha(i), 例如:
```
svm_type c_svc %分类SVM
kernel_type rbf %RBF核函数
gamma 0.1 %gamma 对应 高斯核函数sigma 1/(2*sigma^2) = gamma
nr_class 2 %2分类
total_sv 4 %支持向量数目
rho -0.998178 %判别函数的b, 注意这里用的是 y = W*x -b
label 1 -1
nr_sv 2 2 %每个类别对应的边界上的向量数目,即对应alpha = C
SV
0.5 1:0.3 2:0.4 %支持向量,第一个系数为 y(i)*alpha(i)
0.5 1:0.67 2:0.7
-0.5 1:0.28 2:0.7
-0.5 1:0.48 2:0.5
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment