Libsvm:第1行的输入格式错误 [英] Libsvm : Wrong input format at line 1

查看:267
本文介绍了Libsvm:第1行的输入格式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Libsvm ,并且我得到了以下行为:

I am trying to use Libsvm and I got the following behaviour:

root@bcfd88c873fa:/home/libsvm# ./svm-train myfile
Wrong input format at line 1
root@bcfd88c873fa:/home/libsvm# head -n 5 myfile
2   0:0.00000 8:0.00193 2:0.00000 1:0.00000 10:0.00722
3   6:0.00235 2:0.00000 0:0.00000 1:0.00000 5:0.00155
4   0:0.00000 1:0.00000 2:0.00000 4:0.00187
3   6:0.00121 8:0.00211 1:0.00000 2:0.00000 0:0.00000
3   0:0.00000 2:0.00000 1:0.00000

您能在格式上看到任何错误吗?它可以与其他svm实现配合使用,例如Go中的.

Can you see anything wrong on the format ? It works with other svm implementation such as this one in Go.

谢谢

推荐答案

提供的格式正确. LIBSVM 3.22Java接口确实按预期方式处理了提供的文件.

The provided format is correct. The Java interface of LIBSVM 3.22 does process the provided file as expected.

但是,我也尝试了Windows和Linux界面,它们的行为与您的问题中所述相同.

However, I also tried the Windows and Linux interfaces, which behave as described in your question.

svm-train.exe myfile
Wrong input format at line 1

经过调查,我发现必须对功能ID 进行排序,才能由该工具正确处理(这似乎是一个错误,因为Java界面不受此限制...):

After investigation, I found that the feature-ids have to be sorted to be properly processed by the tool (which seems to be a bug as the Java interface does not suffer from this restriction...):

2   0:0.00000 1:0.00000 2:0.00000 8:0.00193 10:0.00722
3   0:0.00000 1:0.00000 2:0.00000 5:0.00155 6:0.00235
4   0:0.00000 1:0.00000 2:0.00000 4:0.00187
3   0:0.00000 1:0.00000 2:0.00000 6:0.00121 8:0.00211
3   0:0.00000 1:0.00000 2:0.00000

此外,由于LIBSVM使用稀疏数据格式,您可以跳过值为零的特征来简化数据集:

Moreover, as LIBSVM uses sparse-data format you can simplify your dataset by skipping the features with a value of zero:

2   8:0.00193 10:0.00722
3   5:0.00155 6:0.00235
4   4:0.00187
3   6:0.00121 8:0.00211
3   

这篇关于Libsvm:第1行的输入格式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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