1
votes

I am making a sparse arff file but it will not load into Weka. I get the error that I have the wrong number of values in the @attribute class line, it expects 1 and rejects receiving 12. What am I doing wrong? My file looks like this:

%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

Any ideas about what is wrong with my syntax? I followed the example exactly from the book Data Mining by Witten/Frank/Hall. Thanks in advance!

4
Could you write the error, please?jjmartinez
The error reads: weka.core.converters.CSVLoaderfailed to load 'ARFF file for question data.txt'. Reason: wrong number of values. Read 12, expected 1, read Token[EOL], line 477.user3369920
Line 477 is empty, but Line 476 contains the line with @attribute classuser3369920
Have you tried to put a @data with 7 attributes??jjmartinez
The data represents questions, all the questions have different values associated with them since each question has different words (those are the attributes) and word frequencies. So the data is actually (word1 frequency, word2 frequency, ..., classification of the question)user3369920

4 Answers

1
votes

the problem in data section . you must put the index of the class attribute

for example :

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

correct it like the following

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

0
votes

In your document you declared 5 attributes but in @data you are adding 7 attributes, then you should to complete the rest of values in @data. You can see this in the manual

0
votes

The attribute name for the instance class value needs to be listed, too. (See the Sparse ARFF file description.)

Your file:

@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}

Should be:

@data
{126 1, 147 1, 199 1, 56 1, 367 1, 400 1 , myclass Estomatologia}
0
votes
@ATTRIBUTE class string

Try using this instead of

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