【发布时间】:2015-03-30 04:12:04
【问题描述】:
我想在我的 C++ 源代码中直接使用 LIBLINEAR (http://www.csie.ntu.edu.tw/~cjlin/liblinear)。虽然在 MATLAB/JAVA 等语言中使用它似乎很简单,但在 C 语言中似乎很难;例如,阅读README文件,似乎我必须将每个数据矩阵转换为特定的链表格式;来自自述文件
`x' is an array
of pointers, each of which points to a sparse representation (array
of feature_node) of one training vector.
For example, if we have the following training data:
LABEL ATTR1 ATTR2 ATTR3 ATTR4 ATTR5
----- ----- ----- ----- ----- -----
1 0 0.1 0.2 0 0
2 0 0.1 0.3 -1.2 0
1 0.4 0 0 0 0
2 0 0.1 0 1.4 0.5
3 -0.1 -0.2 0.1 1.1 0.1
and bias = 1, then the components of problem are:
l = 5
n = 6
y -> 1 2 1 2 3
x -> [ ] -> (2,0.1) (3,0.2) (6,1) (-1,?)
[ ] -> (2,0.1) (3,0.3) (4,-1.2) (6,1) (-1,?)
[ ] -> (1,0.4) (6,1) (-1,?)
[ ] -> (2,0.1) (4,1.4) (5,0.5) (6,1) (-1,?)
[ ] -> (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (6,1) (-1,?)
所以,看来我不能直接使用矩阵,相反,我必须制作这个 feature_node 的大链表;不存在更简单的系统或任何示例 s.t.我可以用更简单的方式做到这一点吗?
【问题讨论】:
-
不行,没有别的办法。如果您不想受 LIBSVM 强加的类型的限制,那么要么 (i) 不要使用 C/C++ 或 (ii) 修改源以获取您喜欢处理的对象。我不推荐选项(ii)。
标签: regression libsvm c++