2014-06-21 39 views
1

我正在创建一个稀疏的arff文件,但它不会加载到Weka中。我得到错误,我在@attribute类行中有错误的数值,它期望1和拒绝接收12.我在做什么错了?我的文件看起来像这样:weka sparse arff文件

%ARFF file for questions data 
% 

@relation brazilquestions 

@attribute att0 numeric 
@attribute att1 numeric 
@attribute att2 numeric 
@attribute att3 numeric 
%there are 469 attributes which represent my bag of words 
@attribute class {Odontologia_coletiva, Periodontia, Pediatria, Estomatologia, 
Dentistica, Ortodontia, Endodontia, Cardiologia, Terapeutica, 
Terapeutica_medicamentosa, Odontopediatria, Cirurgia} 


@data 
{126 1, 147 1, 199 1, 56 1, 367 1, 400 1 , Estomatologia} 
{155 1, 76 1, 126 1, 78 1, 341 1, 148 1, Odontopediatria} 
%and then 81 more instances of data 

有关我的语法出了什么问题的任何想法?我完全从Witten/Frank/Hall的“数据挖掘”一书中看到了这个例子。提前致谢!

+0

您能写出错误吗? – jjmartinez

+0

错误消息: weka.core.converters.CSVLoader无法加载'问题data.txt的ARFF文件'。 原因: 错误的数值。阅读12,预计1,阅读令牌[EOL],第477行。 – user3369920

+0

第477行是空的,但第476行包含@attribute类的行 – user3369920

回答

0

在您的文档中,您声明了5个属性,但在@data中添加了7个属性,那么您应该在@data中完成剩余的值。 You can see this in the manual

+0

我的属性列表中有469个单词,因为这是我的单词包中的单词总数。我的文件应该是稀少的。 – user3369920

+0

但是你需要完成te属性,你不可以在@data中使用0 0 – jjmartinez

+0

这个列表是完整的,为了简洁起见,我没有列出整个列表,我用“%”表示了这个“%”,其中有469个属性表示我的袋子的话“在原来的帖子里。它有助于查看整个文件吗? – user3369920

0

也需要列出实例类值的属性名称。 (见Sparse ARFF file description。)

您的文件:

@attribute myclass {Odontologia_coletiva, Periodontia, Pediatria, Estomatologia, 
Dentistica, Ortodontia, Endodontia, Cardiologia, Terapeutica, 
Terapeutica_medicamentosa, Odontopediatria, Cirurgia} 

@data 
{126 1, 147 1, 199 1, 56 1, 367 1, 400 1 , Estomatologia} 

应该是:

@data 
{126 1, 147 1, 199 1, 56 1, 367 1, 400 1 , myclass Estomatologia} 
1

在数据部分的问题。 则必须将索引类属性

的例如:

{126 1,147 1,199 1,56 1,367 1,400 1,Estomatologia}

纠正它像以下

{126 1,147 1,199 1,56 1,367 1,400 1,470 Estomatologia}

0
@ATTRIBUTE class string 

尝试使用代替

@attribute class {Odontologia_coletiva, Periodontia, Pediatria, Estomatologia, Dentistica, Ortodontia, Endodontia, Cardiologia, Terapeutica, Terapeutica_medicamentosa, Odontopediatria, Cirurgia}