Angshu Kar | 1 May 2007 02:07
Picon

Re: filterOptions code

Can you please point me to some docs for that?
Also removing the " " doesn't help!

 
On 4/30/07, Peter Reutemann <fracpete <at> waikato.ac.nz> wrote:
> Can anyone please tell where I am going wrong with the following code? It's
> not applying the filter!
>
> I use:
>
> String filter = "weka.filters.unsupervised.attribute.Remove";
> Vector filterOptions = new Vector();
> filterOptions.add(" -V");
...

You have a leading blank there for option "-V". Remove that and it
should work.

BTW you don't have to use the commandline options to setup a filter, you
can also use the usual get/set-methods for configuring a filter.

HTH

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


_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist




--
So little done, so much to do...
_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
Peter Reutemann | 1 May 2007 02:47
Picon
Picon
Favicon

Re: filterOptions code

> Can you please point me to some docs for that?

See the Javadoc of the corresponding class. Shipped with every release 
or snapshot. Or check out the documentation section on the Weka homepage 
regarding online Javadoc for book/developer version.

> Also removing the " " doesn't help!

Right, make also sure that the argument of -R is stored in a separate 
string.

The String array the setOptions method takes is just the one that has 
been passed on from the commandline if one runs a filter from 
commandline. The command prompt/shell breaks up the full string into 
separate strings, depending on quoting and white spaces.
E.g.:
   -V   -R "first,3-5"
will be broken up into:
   [-V]
   [-R]
   [first,3-5]

Note: I've added the "[" and "]" only to demonstrate that there are no 
leading or trailing blanks.

HTH

Cheers, Peter
--

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

_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
Angshu Kar | 1 May 2007 04:33
Picon

Re: filterOptions code

That was an awesome explanation Peter. Thanks a lot.
 
Now about the -V argument: If I run it as you gave in the example,the code will remove all but attributes 3,4,5. Right ?
 
Actullay when I run it I get the opposite result!That is I do:
 
    options[0] = "-V ";                                   
    options[1] = "-R";
    options[2] = "1-6";
    m_Filter = new Remove();                      
    m_Filter.setOptions(options);    
 
Then I use:
 
    m_Filter.setInputFormat(m_Training);
    Instances filteredTrain = Filter.useFilter(m_Training, m_Filter);
    Instances filteredTest = Filter.useFilter(m_Testing, m_Filter);
    filteredTrain.setClassIndex (index);
    filteredTest.setClassIndex(index);
    m_Classifier.buildClassifier(filteredTrain);
    m_Evaluation = new Evaluation(filteredTrain);
    m_Evaluation.evaluateModel(m_Classifier, filteredTest);
 
But I see in the filteredTrain and filteredTest there are all attributes but 1-6 !!!
Doesn't -V invert and then the -R remove?
 
Appreciate your guidance,
Angshu

 
On 4/30/07, Peter Reutemann <fracpete <at> waikato.ac.nz > wrote:
> Can you please point me to some docs for that?

See the Javadoc of the corresponding class. Shipped with every release
or snapshot. Or check out the documentation section on the Weka homepage
regarding online Javadoc for book/developer version.

> Also removing the " " doesn't help!

Right, make also sure that the argument of -R is stored in a separate
string.

The String array the setOptions method takes is just the one that has
been passed on from the commandline if one runs a filter from
commandline. The command prompt/shell breaks up the full string into
separate strings, depending on quoting and white spaces.
E.g.:
  -V   -R "first,3-5"
will be broken up into:
  [-V]
  [-R]
  [first,3-5]

Note: I've added the "[" and "]" only to demonstrate that there are no
leading or trailing blanks.

HTH

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


_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist




--
So little done, so much to do...
_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
Peter Reutemann | 1 May 2007 05:39
Picon
Picon
Favicon

Re: filterOptions code

> Now about the -V argument: If I run it as you gave in the example,the code
> will remove all but attributes 3,4,5. Right ?

No, it will remove all but 1,3,4,5 ("first,3-5"), i.e., 2,6-last will be 
left over.

> Actullay when I run it I get the opposite result!That is I do:
> 
> *    options[0] = "-V ";
>    options[1] = "-R";
>    options[2] = "1-6";
>    m_Filter = new Remove();
>    m_Filter.setOptions(options);*
> 
> Then I use:
> 
> *    m_Filter.setInputFormat(m_Training);
>    Instances filteredTrain = Filter.useFilter(m_Training, m_Filter);
>    Instances filteredTest = Filter.useFilter(m_Testing, m_Filter);
>    filteredTrain.setClassIndex(index);
>    filteredTest.setClassIndex(index);
>    m_Classifier.buildClassifier(filteredTrain);

Don't do a train here! You should provide an untrained model for the 
evaluateModel(Classifier,Instances) method.

>    m_Evaluation = new Evaluation(filteredTrain);
>    m_Evaluation.evaluateModel(m_Classifier, filteredTest);*
> 
> But I see in the filteredTrain and filteredTest there are all attributes 
> but
> *1-6* !!!
> Doesn't -V invert and then the -R remove?

Huh? If you get all attribute apart from 1-6, it's exactly what you 
defined with your options. -V inverts the selection of 1-6, i.e., 7-last 
and removes 7-last therefore.

HTH

Cheers, Peter
--

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

_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
Angshu Kar | 1 May 2007 06:43
Picon

Re: Weka Help

In the given code I see that there is a line:
Instances result = tc.getCurve(eval.predictions(), classIndex);
But when I read the docs on the getCurve method I see the parameter should be FastVector.
I don't get this.
Can anyone please let me know, how should the FastVector object be passed?
 
Thanks,
Angshu

 
On 4/23/07, Peter Reutemann <fracpete <at> waikato.ac.nz> wrote:
> Also can you please let me know how I can generate ROC area (or data to
> draw
> the curves) from code?

Have a look here:
  http://weka.sourceforge.net/wiki/index.php/Generating_ROC_curve

HTH

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


_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist




--
So little done, so much to do...
_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
Angshu Kar | 1 May 2007 06:44
Picon

Re: filterOptions code

I get you Peter. Thanks a lot

On 4/30/07, Peter Reutemann <fracpete <at> waikato.ac.nz> wrote:
> Now about the -V argument: If I run it as you gave in the example,the code
> will remove all but attributes 3,4,5. Right ?

No, it will remove all but 1,3,4,5 ("first,3-5"), i.e., 2,6-last will be
left over.

> Actullay when I run it I get the opposite result!That is I do:
>
> *    options[0] = "-V ";
>    options[1] = "-R";
>    options[2] = "1-6";
>    m_Filter = new Remove();
>    m_Filter.setOptions(options);*
>
> Then I use:
>
> *    m_Filter.setInputFormat(m_Training);
>    Instances filteredTrain = Filter.useFilter(m_Training, m_Filter);
>    Instances filteredTest = Filter.useFilter(m_Testing, m_Filter);
>    filteredTrain.setClassIndex(index);
>    filteredTest.setClassIndex (index);
>    m_Classifier.buildClassifier(filteredTrain);

Don't do a train here! You should provide an untrained model for the
evaluateModel(Classifier,Instances) method.

>    m_Evaluation = new Evaluation(filteredTrain);
>    m_Evaluation.evaluateModel(m_Classifier, filteredTest);*
>
> But I see in the filteredTrain and filteredTest there are all attributes
> but
> *1-6* !!!
> Doesn't -V invert and then the -R remove?

Huh? If you get all attribute apart from 1-6, it's exactly what you
defined with your options. -V inverts the selection of 1-6, i.e., 7-last
and removes 7-last therefore.

HTH

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


_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist




--
So little done, so much to do...
_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
Peter Reutemann | 1 May 2007 07:21
Picon
Picon
Favicon

Re: Weka Help

> In the given code I see that there is a line:
> *Instances result = tc.getCurve(eval.predictions(), classIndex);
> *But when I read the docs on the getCurve method I see the parameter should
> be FastVector.
> I don't get this.
> Can anyone please let me know, how should the FastVector object be passed?

Evaluation.predictions() returns a FastVector - so what's the problem? 
BTW the getCurve method is overloaded.

Cheers, Peter
--

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

_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
Angshu Kar | 1 May 2007 07:24
Picon

apriori

Hi,
 
Can anyone please let me know about any pointers to code implementing apriori?
 
Thanks,
Angshu
_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
Angshu Kar | 1 May 2007 08:03
Picon

Re: Weka Help

I can't find a predictions method in the evaluation class!

On 5/1/07, Peter Reutemann <fracpete <at> waikato.ac.nz> wrote:
> In the given code I see that there is a line:
> *Instances result = tc.getCurve(eval.predictions (), classIndex);
> *But when I read the docs on the getCurve method I see the parameter should
> be FastVector.
> I don't get this.
> Can anyone please let me know, how should the FastVector object be passed?

Evaluation.predictions() returns a FastVector - so what's the problem?
BTW the getCurve method is overloaded.

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


_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist




--
So little done, so much to do...
_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist
Peter Reutemann | 1 May 2007 08:16
Picon
Picon
Favicon

Re: apriori

> Can anyone please let me know about any pointers to code implementing 
> apriori?

Do you wanna re-implement it or just use it in your own code?

If you just wanna use it, then just look at the source code of 
weka.associations.Apriori and it's main method (and follow the code with 
a debugger). You will come to the method evaluate(Associator,String[]) 
of the weka.associations.AssociatorEvaluation class which runs the 
associator with the provided data.

Cheers, Peter
--

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

_______________________________________________
Wekalist mailing list
Wekalist <at> list.scms.waikato.ac.nz
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist

Gmane