Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weka CSV to Arff conversion : IllegalArgumentException: Attribute names are not unique

Tags:

weka

I have a Csv file download from http://yann.lecun.com/exdb/mnist/index.html. I need to convert it to arff file format.

I tried running

java weka.core.converters.CSVLoader /home/saket/Documents/Assignment/NIST7000 > /home/saket/Documents/Myfile.arff 

but it's giving following error

java.lang.IllegalArgumentException: Attribute names are not unique! Causes: '0' '0' '0' '0' '0' '0' '0' 

Then I tried using http://weka.wikispaces.com/Converting+CSV+to+ARFF java code. BUt still same error came.

Can someone please suggest what i am doing wrong

like image 960
saket Avatar asked Oct 20 '12 06:10

saket


People also ask

How do you save data in ARFF format?

Save your dataset in ARFF format by clicking the “File” menu and selecting “Save as…”. Enter a filename with a . arff extension and click the “Save” button.

What is the syntax of ARFF in Weka?

Arff FormatThe @relation tag defines the name of the database. The @attribute tag defines the attributes. The @data tag starts the list of data rows each containing the comma separated fields.

How do I make an ARFF file?

One simple way to do this is in version 3.6. 11 (I'm on a mac) is to open up the Explorer and then in the Preprocess tab select "Open file...", just as you would when you want to open a . arff file. Then where it asks for the File Format at the bottom of the dialog box, change it to .


2 Answers

There was no header fields in the csv. So I created a script and added column0,column1,...,class in the Csv file first line. Then opened that generated csv file in weka.

like image 90
saket Avatar answered Oct 03 '22 23:10

saket


I have encountered the same exception but with a different reason. I used "class" as the attribute name, but this word also appeared in my data as a string (after @data) and Weka did not correctly separate attribute and data. Solved by simply renaming "class" attribute to something else like "s_label".

like image 29
Hao Fu Avatar answered Oct 03 '22 22:10

Hao Fu