Peter Reutemann | 1 Apr 2009 03:23
Picon

Re: Question about the command line

> I am writing my codes using some of the weka classes. I call my class from the command line. Suppose the
command includes:
>
>    -W weka.classifiers.functions.SMO -K weka.classifiers.functions.supportVector.PolyKernel
>
> And I use the following codes to read the above command from the argument:
>
>    String[] tmpOptions;
>    String classname;
>    tmpOptions     = Utils.splitOptions(Utils.getOption("W", args));
>    classname      = tmpOptions[0];
>    tmpOptions[0]  = "";
>    Classifier cls = (Classifier) Utils.forName(Classifier.class, classname, tmpOptions);
>
> So that it will get SMO as the classifier, and the parameters are shown in the tmpOptions, which here would
be "-K weka.classifiers.functions.supportVector.PolyKernel".
>
> However, if I want to add a parameter to PolyKernel, such as change the exponent from the default value 1.0
to 2.0, then the part of the command line would be like:
>
>    -W weka.classifiers.functions.SMO -K weka.classifiers.functions.supportVector.PolyKernel
-- -E 2.0
>
> But using the codes above to analyze the command wouldn't work, because "--" cannot be recognized. My
question is, could you possibly provide me with the updated codes which can read the command which
includes a parameter adding to the sub-classifier. I thought about it for a while, but still could not
figure out how to modify the codes.

You have to use the Utils.partitionOptions(...) method to obtain the
options after the "--". See the setOptions(String[]) method of the
(Continue reading)

Wang, Jing | 1 Apr 2009 05:05
Picon
Favicon

RE: Question about the command line

Thank you. I've looked at the setOptions method in the SingleClassifierEnhancer class, but still cannot
think out a solution. 

In my case, I'll still use Utils.forName method, right? But what would I put in the argument "tmpOptions"?
It's an array of strings, a way I can think of is to put both "-K
weka.classifiers.functions.supportVector.PolyKernel" and "-E 2.0" into tmpOptions. But in this
way, when the Utils.forName method is performed, it will seem both options as belonging to the base
classifier SMO. That's not right. I want the option "-E 2.0" set under PolyKernel, not SMO. 

So how could I give the option containing PolyKernel which has already been set with the option "-E 2.0" to
SMO? Could you give me more details? 

Thanks again,
Jing

> I am writing my codes using some of the weka classes. I call my class from the command line. Suppose the
command includes:
>
>    -W weka.classifiers.functions.SMO -K weka.classifiers.functions.supportVector.PolyKernel
>
> And I use the following codes to read the above command from the argument:
>
>    String[] tmpOptions;
>    String classname;
>    tmpOptions     = Utils.splitOptions(Utils.getOption("W", args));
>    classname      = tmpOptions[0];
>    tmpOptions[0]  = "";
>    Classifier cls = (Classifier) Utils.forName(Classifier.class, classname, tmpOptions);
>
> So that it will get SMO as the classifier, and the parameters are shown in the tmpOptions, which here would
(Continue reading)

Peter Reutemann | 1 Apr 2009 05:16
Picon

Re: Question about the command line

> Thank you. I've looked at the setOptions method in the SingleClassifierEnhancer class, but still cannot
think out a solution.
>
> In my case, I'll still use Utils.forName method, right? But what would I put in the argument "tmpOptions"?
It's an array of strings, a way I can think of is to put both "-K
weka.classifiers.functions.supportVector.PolyKernel" and "-E 2.0" into tmpOptions. But in this
way, when the Utils.forName method is performed, it will seem both options as belonging to the base
classifier SMO. That's not right. I want the option "-E 2.0" set under PolyKernel, not SMO.
>
> So how could I give the option containing PolyKernel which has already been set with the option "-E 2.0" to
SMO? Could you give me more details?

Traditionally, the -W option takes only 1 argument, which is a
classname, and all the other options have to follow after the "--".

Your commandline should look something like this:
some.funky.Classifier -W weka.classifiers.functions.SMO <other
options> --  -K "weka.classifiers.functions.supportVector.PolyKernel
-E 2"

The classifier "some.funky.Classifier" would be derived from
SingleClassifierEnhancer. And SingleClassifierEnhancer automatically
uses the options after the "--"  and supplies the classifier specified
with -W (in this case, this is SMO).

Cheers, Peter
--

-- 
Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ
http://www.cs.waikato.ac.nz/~fracpete/           Ph. +64 (7) 858-5174

(Continue reading)


Gmane