tags:

views:

122

answers:

2

Has anyone done this? Is there any documentation on how to use this parser module? I've looked through the code but it's not clear to me to how to actually use the data after it's been parsed.

The file src\main\java\weka\core\converters\ArffLoader.java (which I assume is where the Arff parsing happens) has these instructions:

  • Typical code for batch usage:
  • BufferedReader reader = new BufferedReader(new FileReader("/some/where/file.arff"));
  • ArffReader arff = new ArffReader(reader);
  • Instances data = arff.getData();
  • data.setClassIndex(data.numAttributes() - 1);

But what else can I do with 'data'? How do I access each row and the values in each row?

(By the way, I'm new to Java. If I run this code, is there some kind of introspection I could do on data to see what it offers? That's what I would do in Python.)

(I'm also open to suggestions for a simpler open source Arff parser to use in my project if one exists.)

+1  A: 

It looks to me that your answer lies in the Instances class - that is where the data is stored.

I would find the API of the Instances classes, either by locating or generating its javadoc, or simply perusing its source. The methods of this class should allow you to manipulate the data that has been loaded from the ARFF file.

bguiz
+1  A: 

You can use Weka from Python, and get introspection. I've been successfully using Weka from JRuby to do the same thing. Google "Weka documentation" to find the page that links to the API for the stable and development version. I don't have enough reputation to put a second link in my answer :)

michaeltwofish