2014-06-21 41 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}