本文介绍了Libsvm模型文件格式没有模型编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用libsvm进行文档分类.我在项目中使用svm.cc和svm.h.然后,我叫svm_train.我使用svm_save_model将模型保存在文件中.

I am using libsvm for document classification. I use svm.cc and svm.h in my project. I then call svm_train. I save the model in a file using svm_save_model.

我有类别. svm模型文件为:

I have there categories. The svm model file is:

svm_type c_svc
kernel_type rbf
gamma 0.001002
nr_class 3
total_sv 9
rho -0.000766337 0.00314423 0.00387654
label 0 1 2
nr_sv 3 3 3
SV
1 1 1:0.001 2:0.001 3:0.012521912 5:0.001 15:0.012521912 17:0.012521912 23:0.001
1 1 1:0.001 2:0.014176543 4:0.093235799 6:0.001 7:0.0058630699 9:0.040529628 10:0.001
1 1 11:0.38863495 33:0.08295242 46:0.041749886 58:0.08295242 89:0.08295242 127:0.15338862 -1 1 5:0.001 8:0.0565 10:0.001 13:0.001 18:0.0565 21:0.021483399 34:0.12453384 36:0.001
-1 1 13:0.034959612 34:0.090130132 36:0.034959612 45:0.034959612 47:0.12019824
-1 1 5:0.001 8:0.048037273 13:0.001 18:0.048037273 29:0.14715472 30:0.018360058 36:0.001
-1 -1 9:0.0049328688 12:0.090902344 18:0.1156038 27:0.0049328688 31:0.015144206

以index:value形式表示的矢量值之前的1和-1是什么?

What are 1 and -1 before the vector values in the form of index:value ?

推荐答案

来自libsvm常见问题解答:

From the libsvm FAQ:

在模型文件中, 在参数和其他信息(例如label)之后,每一行 表示支持向量.支持向量按顺序列出 前面显示的标签". (即来自 标签"列表首先分组,依此类推.)如果k是总数 类,在类j的支持向量前面,有k-1个 系数y * alpha,其中alpha是以下项的对偶解 两类问题:1 vs j,2 vs j,...,j-1 vs j,j vs j + 1,j vs 在前j-1个系数中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|                    |
 +-+-+-+--------------------+

http://www.csie.ntu.edu .tw/〜cjlin/libsvm/faq.html#f402

这篇关于Libsvm模型文件格式没有模型编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 09:50