从libsvm模型文件中提取系数/权重 [英] Extract coefficients/weights from libsvm model file

查看:424
本文介绍了从libsvm模型文件中提取系数/权重的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 libsvm 创建2类分类器. 我希望提取./svm-train training.training model.model

I am using libsvm for creating a 2-classes classifier. I wish to extract the coefficient/weight of each feature used by the model generated by ./svm-train training.training model.model

model.model文件如下所示:

svm_type c_svc
kernel_type rbf
gamma 8
nr_class 2
total_sv 442
rho 21
label 1 -1
nr_sv 188 254
SV
7080.357768871263 0:0 1:0.00643 2:0.01046 3:0.00963 4:0.02777 5:0.04338 19:0.04468 
528.7111702760092 0:0 1:0.00058 3:0.00086 6:0.01158 7:0.0028 9:0.08991 13:0.0096 
...
391.7649705739246 0:0 1:0.00055 3:0.00082 5:0.04615 7:0.06374 21:0.00374 31:0.00339 33:0.00395 38:0.16343 
...
-564.1329424321915 0:0 1:0.00709 2:0.00384 3:0.00709 5:0.00399 9:0.01457 10:0.01244 11:0.0206 17:0.02124 20:0.00565 23:0.00846 27:0.04692 33:0.04271 35:0.02389 36:0.00859 39:0.02014 

我怎么知道svm-predict [options] test.test model.model out.out将使用哪些系数/权重?最后一行的那些?

How do I know which coefficients/weights will be used by svm-predict [options] test.test model.model out.out ? The ones from the last line ?

谢谢, M.

推荐答案

根据官方

The model file generated by LIBSVM consists, according to the offical FAQ entry, of the following information:

在模型文件中,在参数和其他信息之后,例如 标签,每行代表一个支持向量. 支持载体以前面显示的标签"的顺序列出. (即来自 标签"列表中的头等舱首先分组,依此类推.)如果k 是类的总数,位于类中的支持向量之前 j,有k-1个系数y * alpha,其中alpha是的对偶解 以下两类问题:1 vs j,2 vs j,...,j-1 vs j,j vs j + 1,j vs j + 2,...,j vs k和y = 1在前j-1个系数中,y = -1在 其余的k-j系数.例如,如果有4个班级, 该文件如下所示:

In the model file, after parameters and other informations such as labels , each line represents a support vector. Support vectors are listed in the order of "labels" shown earlier. (i.e., those from the first class in the "labels" list are grouped first, and so on.) If k is the total number of classes, in front of a support vector in class j, there are k-1 coefficients y*alpha where alpha are dual solution of the following two class problems: 1 vs j, 2 vs j, ..., j-1 vs j, j vs j+1, j vs j+2, ..., j vs k and y=1 in first j-1 coefficients, y=-1 in the remaining k-j coefficients. For example, if there are 4 classes, the file looks like:

+-+-+-+--------------------+
|1|1|1|                    |
|v|v|v|  SVs from class 1  |
|2|3|4|                    |
+-+-+-+--------------------+
|1|2|2|                    |
|v|v|v|  SVs from class 2  |
|2|3|4|                    |
+-+-+-+--------------------+
|1|2|3|                    |
|v|v|v|  SVs from class 3  |
|3|3|4|                    |
+-+-+-+--------------------+
|1|2|3|                    |
|v|v|v|  SVs from class 4  |
|4|4|4|                    |
+-+-+-+--------------------+

还有一个示例如何读取此数据以便为二进制分类器计算w.

There is also an example of how to read this data in order to compute w for a binary classifier.

这篇关于从libsvm模型文件中提取系数/权重的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆