Issue
I am interested in including some results that come from Weka in a system. I tried to look for similar functions in Rweka and in python, but I could not so I think that running the process from a Linux terminal would solve my problem. In the "select attributes" pannel, I chose:
Attribute evaluator: CfsSubsetEval -P 1 -E 1 Search Method: MultiObjectiveEvolutionarySearch -generations 20 -population-size 100 -seed 1 -algorithm 0 -report-frequency 20 -log-file /home/aurorax/Git_repos/postdoc/QoI/to_submit/weka-3-8-5
When I run it, it shows the following "code":
=== Run information ===
Evaluator: weka.attributeSelection.CfsSubsetEval -P 1 -E 1
Search: weka.attributeSelection.MultiObjectiveEvolutionarySearch -generations 20 -population-size 100 -seed 1 -algorithm 0 -report-frequency 20 -log-file /home/aurorax/Git_repos/postdoc/QoI/to_submit/weka-3-8-5
Relation: metricsAndRMSE1-weka.filters.unsupervised.instance.RemoveDuplicates
Instances: 293
Attributes: 12
qcomp
qpla
qout
qoutMean
qoutMedian
qprob
qrec
qinvMean
qinvMedian
qBMEmean
qBMEmedian
rmse1
Evaluation mode: evaluate on all training dat
And at the end of it, it shows what I am interested in, that is on what attributes should be selected:
Selected attributes: 1,3,11 : 3
qcomp
qout
qBMEmedian
Could you please provide me some guidance? I already checked some of the documentation, but could not find a way to do this.
Thank you very much!
Solution
Yes, you can run evaluators from the command-line, though not commonly used.
You can query the evaluator's help like this, e.g., for CfsSubsetEval
:
java -cp weka.jar weka.attributeSelection.CfsSubsetEval -h
The output is split into General options and ones specific to CfsSubsetEval. The general ones are:
General options:
-h
display this help
-i <name of input file>
Sets training file.
-c <class index>
Sets the class index for supervised attribute
selection. Default=last column.
-s <class name>
Sets search method for subset evaluators.
-x <number of folds>
Perform a cross validation.
-n <random number seed>
Use in conjunction with -x.
Assuming that your dataset is located in /your/dataset.arff
and the class attribute is the last
one, you get the following:
java -cp weka.jar weka.attributeSelection.CfsSubsetEval \
-i /your/dataset.arff \
-c last \
-s "SEARCH_METHOD_CLASSNAME + OPTIONS" \
[other CfsSubsetEval options]
In order to ensure that all packages get loaded correctly, you should use the weka.Run
class to launch your attribute selection. This gives us:
java -cp weka.jar weka.Run \
weka.attributeSelection.CfsSubsetEval \
-i /your/dataset.arff \
-c last \
-s "SEARCH_METHOD_CLASSNAME + OPTIONS" \
[other CfsSubsetEval options]
Or, in your case:
java -cp weka.jar weka.Run \
weka.attributeSelection.CfsSubsetEval \
-i /your/dataset.arff \
-c last \
-s "weka.attributeSelection.MultiObjectiveEvolutionarySearch -generations 20 -population-size 100 -seed 1 -algorithm 0 -report-frequency 20 -log-file /home/aurorax/Git_repos/postdoc/QoI/to_submit/weka-3-8-5" \
-P 1 -E 1
Final note: Be careful to escape double quotes and backslashes correctly. If your search method command-line should contain them (not in the case that you posted), you need to escape them with backslashes.
For example:
weka.attributeSelection.FunkySearch -b "some option \"with nested bits\""
Will change into this as part of the command-line:
...
-s "weka.attributeSelection.FunkySearch -b \"some option \\"with nested bits\\"\""
...
Answered By - fracpete