Csv to MOA arff format

677 views
Skip to first unread message

Andrea Dal Pozzolo

unread,
Nov 23, 2013, 12:25:19 PM11/23/13
to moa-...@googlegroups.com
Hello, 

I've a csv file that I want to convert into a stream.
I've tried to convert it into a arff file using the foreing package in R for weka and then import it to MOA but I get the following error:

java.lang.RuntimeException: ArffFileStream failed to read instance from stream.
at moa.streams.ArffFileStream.readNextInstanceFromFile(ArffFileStream.java:162)
at moa.streams.ArffFileStream.restart(ArffFileStream.java:142)
at moa.streams.ArffFileStream.prepareForUseImpl(ArffFileStream.java:89)
at moa.options.AbstractOptionHandler.prepareForUse(AbstractOptionHandler.java:76)
at moa.options.AbstractOptionHandler.prepareClassOptions(AbstractOptionHandler.java:156)
at moa.tasks.AbstractTask.doTask(AbstractTask.java:52)
at moa.tasks.TaskThread.run(TaskThread.java:76)
Caused by: java.io.IOException: number expected, read Token[FALSE], line 38
at weka.core.converters.ArffLoader$ArffReader.errorMessage(ArffLoader.java:327)
at weka.core.converters.ArffLoader$ArffReader.getInstanceFull(ArffLoader.java:721)
at weka.core.converters.ArffLoader$ArffReader.getInstance(ArffLoader.java:523)
at weka.core.converters.ArffLoader$ArffReader.readInstance(ArffLoader.java:488)
at weka.core.Instances.readInstance(Instances.java:1039)
at moa.streams.ArffFileStream.readNextInstanceFromFile(ArffFileStream.java:150)
... 6 more

What I did was
1) load csv into R
2) use  write.arff(Trx,file="Trx.arff") to write R data.frame as arff file for weka
3) 
java -cp moa.jar -javaagent:sizeofag.jar moa.DoTask \

"EvaluatePeriodicHeldOutTest -l (OzaBag -l trees.HoeffdingTree -s 10)\

 -s (ArffFileStream -f /Users/Andrea/Documents/Education/MOA/data/Trx/Trx.arff)" > htresult.csv


I guess the arff format of weka is different from the arff format in MOA?

thanks

Andrea

Albert Bifet

unread,
Nov 25, 2013, 4:41:57 PM11/25/13
to moa-...@googlegroups.com
The format of arff file used in moa is very similar to the Weka format
file. You may try to convert the file using weka:

http://weka.wikispaces.com/Converting+CSV+to+ARFF

Cheers, Albert
> --
> You received this message because you are subscribed to the Google Groups
> "MOA users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to moa-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Andrea Dal Pozzolo

unread,
Nov 25, 2013, 6:08:29 PM11/25/13
to moa-...@googlegroups.com, abi...@cs.waikato.ac.nz
I found the problem, the function write.arff() in R is not able to handle logical classes.

Thanks

Andrea
Reply all
Reply to author
Forward
0 new messages