What does each item mean in svmLight Format

余生颓废 提交于 2019-12-12 20:52:22

问题


I am very confused about what each part means in a svmLight data format. For example:

(label/target, [(feature, value), ...], queryid)

Does the label means the rank of the data and queryid is the id of the object?

For example: for the following item:

2 qid:1 1:4.000000 2:2.772589 3:0.266667 4:0.258154 5:37.330565 6:11.431241 7:37.307017 8:1.213630 9:21.342267 10:10.842279 11:15.634736 12:2.749495 13:-39.467448 14:-37.791635 15:-38.002289 16:14.000000 17:5.634790 18:0.063927 19:0.063290 20:28.303065 21:9.340024 22:24.809801 23:0.231553 24:52.396216 25:1.692954 26:16.619600 27:2.810583 28:-45.733775 29:-44.612550 30:-44.823263 31:18.000000 32:6.579251 33:0.076923 34:0.076079 35:27.701632 36:9.139690 37:23.819476 38:0.277200 39:67.283604 40:1.847508 41:19.559974 42:2.973485 43:-44.687666 44:-43.467574 45:-43.302044 #docid = 346319

Does 2 means the rank/ the target value of the object? Then what does qid or docid means for the file?

Thank you!


回答1:


The leading number is indeed the "target" of this object. The qid:1 part is used in constraining pairwise difference between such objects. The docid, or rather everything after the final # is an info string that

can be used to pass additional information to the kernel (e.g. non feature vector data)

(source).

The general format for each object is given in the official source, under the heading "How to use":

<line> .=. <target> <feature>:<value> <feature>:<value> ... <feature>:<value> # <info>
<target> .=. +1 | -1 | 0 | <float> 
<feature> .=. <integer> | "qid"
<value> .=. <float>
<info> .=. <string> 

Note that the format you specify

(label/target, [(feature, value), ...], queryid)

is that of pysvmlight, a Python binding to the SVM-Light support vector machine library made by Thorsten Joachims, which I quoted earlier. You'll need to write a parser to parse the datafiles native to svmlight into the format that pysvmlight uses. There is at least one example on StackOverflow, even though it does not take into account the qid, but it shouldn't be too difficult to add when you read that parser's code.



来源:https://stackoverflow.com/questions/37571930/what-does-each-item-mean-in-svmlight-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!