moa using java code

1,487 views
Skip to first unread message

droid

unread,
Jun 20, 2013, 3:56:08 AM6/20/13
to moa-...@googlegroups.com
In order to run the moa example (say naive bayes), i am encountering the following problem...

Exception in thread "main" java.lang.IncompatibleClassChangeError: Found class weka.core.Instance, but interface was expected
    at moa.classifiers.AbstractClassifier.trainOnInstance(AbstractClassifier.java:140)
    at moa.classifiers.bayes.Nbc.main(Nbc.java:49)


all i am doing is trying to use NB java code... provide two arff files to it( one to train and other to test).

// load data
        ArffLoader loader = new ArffLoader();
        loader.setFile(new File(args[0]));---------------------------------------------> 1 arff file location
        String str="1.arff";------------------------------------------------------------------>2 arff file location
        Instances structure = loader.getStructure();
        ArffLoader loader2 = new ArffLoader();
        loader2.setFile(new File(str));
        Instances test = loader2.getDataSet();
        structure.setClassIndex(structure.numAttributes() - 1);
        test.setClassIndex(test.numAttributes() - 1);
       
       
     // train NaiveBayes
        NaiveBayes nb = new NaiveBayes();
        nb.resetLearningImpl();
        Instance current;
        while ((current = loader.getNextInstance(structure)) != null)
        nb.trainOnInstance(current);--------------------------------------------------------------->SHOWING ME ERROR FOR THIS PARTICULAR CALL
        

Plz help me out?

Albert Bifet

unread,
Jun 20, 2013, 4:24:55 AM6/20/13
to moa-...@googlegroups.com
> java.lang.IncompatibleClassChangeError: Found class weka.core.Instance, but interface was expected

Instance was a class in previous Weka versions, but now is an interface in MOA and Weka. You may have a conflict with old MOA or Weka jar files in your java class path.

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.
 
 

droid

unread,
Jun 21, 2013, 6:38:24 AM6/21/13
to moa-...@googlegroups.com, abi...@cs.waikato.ac.nz
Thank you for the quick response earlier.

When i try to use naive bayes classifier object defined under weka(weka.classifiers.bayes.NaiveBayes) above code works perfectly fine.
(for this particular case i added only weka(v3.6).jar to classpath.)
"current" is just passed to the "updateClassifier(current);"

but when i run the same code with two changes as follows
1. object of naive bayes created from moa.classifiers.bayes.NaiveBayes
2. moa sizeofag and weka(3.6)- are the 3 jars added to classpath.
code is giving the error earlier mentioned.

ultimately the method trainOnInstanceImpl is to be provided with an "Instance" type of parameter.

so what am i doing wrong here? i am using weka(3.6) and moa(08 2012 release).

ps: plz bear with me even though it may be a silly one :D
Using just the NB code(or any other that suits the need), that's what i am looking for.... if you know any source that explains such workarounds with the code so plz do share(or rather examples would be appreciated).

Albert Bifet

unread,
Jun 21, 2013, 6:48:46 AM6/21/13
to moa-...@googlegroups.com
Try using weka 3.7.9, and tell me if this solves your problem.

Cheers, Albert

droid

unread,
Jul 4, 2013, 6:04:16 AM7/4/13
to moa-...@googlegroups.com, abi...@cs.waikato.ac.nz
when i try to use the Clustream clustering on the "yeast" dataset following error occurs.

Task failed. Reason:
java.lang.NullPointerException
    at moa.gui.BatchCmd.exportCSV(BatchCmd.java:228)
    at moa.gui.BatchCmd.runBatch(BatchCmd.java:123)
    at moa.tasks.EvaluateClustering.doMainTask(EvaluateClustering.java:96)
    at moa.tasks.MainTask.doTaskImpl(MainTask.java:50)
    at moa.tasks.AbstractTask.doTask(AbstractTask.java:57)
    at moa.tasks.TaskThread.run(TaskThread.java:76)

this is the command that i ran on bash.
java -cp moa.jar -javaagent:sizeofag.jar moa.DoTask "moa.tasks.EvaluateClustering -l clustream.Clustream -s (FileStream -f (yeast_clusterin.arff))"  > result_yeast.csv

Thanks in advance!!

Marwan Hassani

unread,
Jul 4, 2013, 5:30:10 PM7/4/13
to moa-...@googlegroups.com, abi...@cs.waikato.ac.nz
This is a known bug that will be solved in the next version of MOA. It is combined with reading external arff files within linux from the command line. Until the next version of MOA appears, you can run this task from the MOA GUI.

Regards, Marwan

droid

unread,
Jul 10, 2013, 6:11:43 AM7/10/13
to moa-...@googlegroups.com, abi...@cs.waikato.ac.nz
After a few workarounds on MOA framework, now i would like to know how these classifiers are used in the real world for catering to different business needs.
Like naive bayes is used in spam filtering,so where hoeffding trees could prove significant or rather how to decide to go for meta classifiers?
Or is it that one has to figure what the need/task is beforehand and then perform comparison among 3 -4 classifiers as one can not be sure as to what would yield satisfactory results.

Any books or other reference material in this regard by anyone would really be appreciated.

Thanks in advance !!

Albert Bifet

unread,
Jul 11, 2013, 8:34:11 AM7/11/13
to moa-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages