Encipher
Encipher

Reputation: 2946

data file to .arff file for Weka software

I would like to transfer a data file to .arff file. I am using Weka software for my project.

I found few transfer methods on the Internet.

  1. I can change the file extension from save as option of a file.

  2. I can change the data file to .csv and then open it using Weka -> tools -> arff views then save it as .arff file.

These two methods did not work.

I got the error after saving the file .arff and then try to open it.

enter image description here

Link for data file this link

Link for csv file this link

code to transfer data file to csv

import pandas as pd
data = pd.read_csv('breast-cancer-wisconsin.data')
data.columns = ['code','Clump Thickness','UniformityOfCellSize','UniformityOfCellShape','MarginalAdhesion','SingleEpithelialCellSize','BareNucloi','BlandChromatin','NormalNucleoli','Mitoses','Class']
data.to_csv('breast-cancer-wisconsin.csv', index=False, encoding='utf-8')

Now I would like to know how can I transfer data file into .arff?

Solution link did not help.

Thank you

Upvotes: 0

Views: 784

Answers (2)

fracpete
fracpete

Reputation: 2608

@StatsPy gave you a correct answer for how you can convert your CSV file using the command-line.

Here are the steps how you can do that in the Weka user interface:

  • start Weka
  • launch the Weka Explorer
  • click on Open...
  • in the open dialog change the file type to CSV data files
  • select the CSV file that you want to open
  • not necessary in this case, but if you needed to tweak the loader's options: tick the Invoke options dialog checkbox to prompt you with a dialog for customizing the loader's options
  • click on Open

I'm not familiar with that dataset, but it might be the case that not all attributes should be treated as numeric (e.g., the class attribute). If that is the case, then you can use the NumericToNominal filter in the Preprocess panel to convert the relevant attribute indices (1-based) to nominal ones.

Once you are done, you can save your dataset by clicking on Save... (just make sure your file type in the save dialog is set to ARFF data files) and providing a file name.

Upvotes: 1

merchmallow
merchmallow

Reputation: 794

Did you try: java -cp /path to weka.jar weka.core.converters.CSVLoader file.csv > file.arff ?

Upvotes: 1

Related Questions