run a new classifier in moa

496 views
Skip to first unread message

Zahra Rezaie

unread,
Apr 26, 2016, 6:18:48 AM4/26/16
to MOA users
Hi

I want to slightly change the code of one of moa classifiers. To test how it works and what the process for creating a new classifier is, I copied the code of "DecisionStump" classifier and created a java class out of it. Actually I have not changed it. So what next? How can I run this, let's assume, new classifier from windows cmd through moa? Is it even possible to do it because I have not found anything about it on the Internet or moa manual!

Could somebody help me out and explain how to run my own classifier on moa? If there is no way to do it, what are my alternatives?

Thanks in advance!

Christophe Salperwyck

unread,
Apr 26, 2016, 8:28:30 AM4/26/16
to moa-...@googlegroups.com
Hi,

In manual.pdf from the website you have everything from page 17 to build and deploy your own classifier.

Cheers,
Christophe

--
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/d/optout.

Zara Rezaie

unread,
Apr 26, 2016, 11:32:43 AM4/26/16
to MOA users
Thanks for the response. As I said I read the manual. It is explained how to create and compile a new classifier from page 17 to 23. I created my DesisionStumpTutorial.class based on its instructions. This chapter ends like this:

javac -cp moa.jar DecisionStumpTutorial.java
This produces compiled java class file DecisionStumpTutorial.class.
Before continuing, the commands below set up directory structure to reflect
the package structure:
mkdir moa
mkdir moa/classifiers
cp DecisionStumpTutorial.class moa/classifiers/
The class is now ready to use.
 
Here is where exactly I am, actually where I'm stuck! So next step? If it helps, I'm new to both moa and java programming. 

Christophe Salperwyck

unread,
Apr 26, 2016, 4:00:53 PM4/26/16
to moa-...@googlegroups.com
If MOA starts you should be able to see the new classifier. You can also package the .class into a jar using Eclipse or maven. You might ask some IT guys to do that if you never did it before.

Zara Rezaie

unread,
Apr 27, 2016, 5:08:14 AM4/27/16
to MOA users
I checked the GUI but there wasn't added any new classifier on the list of learners.

If I wanted to run the DecisionStump itself, the command in the cmd would be like this:

java -cp moa.jar -javaagent:sizeofag.jar moa.DoTask "EvaluatePeriodicHeldOutTest -l trees.DecisionStump -s generators.WaveformGenerator -n 1000 -i 100000 -f 10000" > dsresult.csv


and it works fine. Now I want to use DecisionStumpTutorial classifier which is located in "moa/classifiers" and the "moa" folder is in the same directory as moa.jar. What would be the command like? I tried the command above just by replacing the name of classifier but it didn't work and I got this error:


java.lang.Exeption: problem with options to 'EvaluatorPeriodicHeldOutTest'

.

.

Caused by: java.lang.illegalArgumentExeption: problem with option: learner

.

.

Caused by: java.lang.Exeption: class not found: trees.DecisionStumpTutorial




Albert Bifet

unread,
Apr 27, 2016, 5:36:23 AM4/27/16
to MOA users
Try adding . to the java class path:

java -cp .:moa.jar -javaagent:sizeofag.jar .. (Linux)

java -cp .;moa.jar -javaagent:sizeofag.jar .. (Windows)

Cheers, Albert

Zara Rezaie

unread,
Apr 27, 2016, 7:08:36 AM4/27/16
to MOA users, abi...@cs.waikato.ac.nz
Those dots at the end of the command must be replaced by something else? Because I run that and I got this error:
Error: Could not find or load main class ..

I thought I'm supposed to replace it with my own class' name (with and without the full directory), but again that error appeared. (Now I have also made DecisionStumpTutorial.jar file.)

Zahra Rezaie

unread,
Apr 27, 2016, 7:20:42 AM4/27/16
to moa-...@googlegroups.com

I also created a CLASSPATH variable manually from the windows settings and set its value = .; but it didn't help me with running my own classifier.

You received this message because you are subscribed to a topic in the Google Groups "MOA users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/moa-users/o4uMy-0C5Ho/unsubscribe.
To unsubscribe from this group and all its topics, send an email to moa-users+...@googlegroups.com.

Albert Bifet

unread,
Apr 27, 2016, 7:30:07 AM4/27/16
to MOA users
Are you using Windows or Linux?

Cheers, Albert

Zahra Rezaie

unread,
Apr 27, 2016, 7:31:33 AM4/27/16
to moa-...@googlegroups.com

Windows 7. Sorry, I thought I'd mentioned it.

Albert Bifet

unread,
Apr 27, 2016, 7:46:37 AM4/27/16
to MOA users
Try then

java -cp .;moa.jar -javaagent:sizeofag.jar moa.DoTask "EvaluatePeriodicHeldOutTest -l DecisionStumpTutorial -s generators.WaveformGenerator -n 1000 -i 100000 -f 10000" > dsresult.csv

Cheers, Albert

Zara Rezaie

unread,
Apr 27, 2016, 8:26:33 AM4/27/16
to MOA users, abi...@cs.waikato.ac.nz
Thanks I've attached a screenshot from cmd error I got. Anyway, they are the same as before. There are some lines between which I haven't typed but you can see in the screenshot if they're needed.

java.lang.Exeption: problem with options to 'EvaluatorPeriodicHeldOutTest'

.

.

Caused by: java.lang.illegalArgumentExeption: problem with option: learner

.

.

Caused by: java.lang.Exeption: class not found: trees.DecisionStumpTutorial


Thank you for your time

error.png

Albert Bifet

unread,
Apr 27, 2016, 9:15:22 AM4/27/16
to MOA users
It seems that it can not find DecisionStumpTutorial on the java classpath. What version of MOA are you using? What do you have have in the moa folder?

Cheers, Albert

Zara Rezaie

unread,
Apr 27, 2016, 9:27:49 AM4/27/16
to MOA users, abi...@cs.waikato.ac.nz
moa 2014.11. I kept coming across some errors while installing version 2015, so installed 2014. the moa folder contains, Folders: bin, doc, examples, lib, license, src and moa (which is created by myself consists classifiers/DecisionStumpTutorial.class) and Files: moa.jar and sizeofag.jar. 

Albert Bifet

unread,
Apr 27, 2016, 9:45:32 AM4/27/16
to MOA users
What is the package line inside DecisionStumpTutorial.java?

Cheers, Albert

Zara Rezaie

unread,
Apr 27, 2016, 11:08:52 AM4/27/16
to MOA users, abi...@cs.waikato.ac.nz
It used to be package moa.classifiers.trees; which I modified it to package moa.classifiers; and then it worked from the command line. Thank you very much!
Message has been deleted
Message has been deleted

Albert Bifet

unread,
Jul 8, 2016, 7:56:54 AM7/8/16
to MOA users
>> Caused by: java.lang.Exception: Class not found: meta.NewMetaClassifier

It seems that MOA is not finding the classifier. Can you check that
NewMetaClassifier file has the line "package moa.classifiers.meta;"
inside?

Thanks, Albert

On Fri, Jul 8, 2016 at 12:02 PM, Leandro <leandr...@leicester.ac.uk> wrote:
>
> Hello Albert,
>
> I've created a new MOA classifier in moa.classifiers.meta. It runs fine from
> the GUI. However, from the command line, I'm getting the following error:
>
> java.lang.Exception: Problem with options to 'EvaluatePrequential'.
>
>
> (...)
>
>
> at moa.options.ClassOption.cliStringToObject(ClassOption.java:153)
>
> at moa.DoTask.main(DoTask.java:133)
>
> Caused by: java.lang.IllegalArgumentException: Problems with option: learner
>
> at moa.options.ClassOption.setValueViaCLIString(ClassOption.java:66)
>
> at com.github.javacliparser.Options.setViaCLIString(Options.java:141)
>
> at moa.options.ClassOption.cliStringToObject(ClassOption.java:151)
>
> ... 1 more
>
> Caused by: java.lang.Exception: Class not found: meta.NewMetaClassifier
>
> at moa.options.ClassOption.cliStringToObject(ClassOption.java:125)
>
> at moa.options.ClassOption.setValueViaCLIString(ClassOption.java:63)
>
> ... 3 more
>
>
> where NewMetaClassifier is my new classifier.
>
>
>
> The command line is the following:
>
>
> java -cp ~/Leandro\'s\
> Files/Work/Approaches/MOA-2016.04-leandro/moa-leandro.jar:~/Leandro\'s\
> Files/Work/Approaches/MOA-2016.04-leandro/lib/sizeofag-1.0.0.jar moa.DoTask
> \
>
> "EvaluatePrequential -l meta. NewMetaClassifier \
>
> -s (ArffFileStream -f (/Users/llm11/Leandro's Files/trainingset.arff) -c 15)
> \
>
> -e (FadingFactorClassificationPerformanceEvaluator -a 0.99) \
>
> -f 1 -d (/Users/llm11/Leandro's Files/tmp.csv)"
>
>
> It seems a similar error to the one on this thread. However, even if I move
> the class from moa.classifiers.meta to moa.classifiers, it doesn't work.
>
>
> I ran a similar command line with meta.OzaBag and it worked fine:
>
>
> java -cp ~/Leandro\'s\
> Files/Work/Approaches/MOA-2016.04-leandro/moa-leandro.jar:~/Leandro\'s\
> Files/Work/Approaches/MOA-2016.04-leandro/lib/sizeofag-1.0.0.jar moa.DoTask
>
> "EvaluatePrequential -l meta.OzaBag \
>
> -s (ArffFileStream -f (/Users/llm11/Leandro's Files/trainingset.arff) -c 15)
>
> -e (FadingFactorClassificationPerformanceEvaluator -a 0.99) \
>
> -f 1 -d (/Users/llm11/Leandro's Files/tmp.csv)"
>
>
> Any ideas on what the problem may be?
>
>
> Many thanks,
>
> Leandro.

Leandro

unread,
Jul 8, 2016, 6:06:28 PM7/8/16
to MOA users, abi...@cs.waikato.ac.nz

Hi Albert,

Thank you -- I found what the problem was. I thought that deleting the message from the group might save your time, but now I see that you probably receive the emails directly in your inbox rather than checking them in the group. Sorry about that.

Anyway, it might be useful for me to tell here what the problem was. The error message really suggests that MOA was not finding the NewMetaClassifier. However, the problem was not in MOA finding the NewMetaClassifier itself, but a class that I was instantiating inside the NewMetaClassifier. The .jar of this class was not in the classpath.

Best regards,
Leandro.

Albert Bifet

unread,
Jul 9, 2016, 10:11:01 AM7/9/16
to MOA users
Thanks Leandro!

Cheers, Albert
Reply all
Reply to author
Forward
0 new messages