From command-line, python-weka-wrapper behaves similar to Weka itself, i.e., the command-line. Most of the general options are available, as well as the following:
The following examples are all for a Linux bash environment. Windows users have to replace forwarding slashes / with backslashes \ and place the command on a single line with the backslashes \ at the end of the lines removed.
Artifical data can be generated using one of Weka’s data generators, e.g., the Agrawal classification generator:
python weka/datagenerators.py \
-o /tmp/out.arff \
weka.datagenerators.classifiers.classification.Agrawal
Filtering a single ARFF dataset, removing the last attribute using the Remove filter:
python weka/filters.py \
-i /my/datasets/iris.arff \
-o /tmp/out.arff \
-c last \
weka.filters.unsupervised.attribute.Remove \
-R last
For batch filtering, you can use the -r and -s options for the input and output for the second file.
Example on how to cross-validate a J48 classifier (with confidence factor 0.3) on the iris UCI dataset:
python weka/classifiers.py \
-t /my/datasets/iris.arff \
-c last \
weka.classifiers.trees.J48
-C 0.3
Example on how to perform classes-to-clusters evaluation for SimpleKMeans (with 3 clusters) using the iris UCI dataset:
pythonn weka/clusterers.py \
-t /my/datasets/iris.arff \
-c last \
weka.clusterers.SimpleKMeans
-N 3
You can perform attribute selection using BestFirst as search algorithm and CfsSubsetEval as evaluator as follows:
python weka/attribute_selection.py \
-i /my/datasets/iris.arff \
-x 5 \
-n 42 \
-s "weka.attributeSelection.BestFirst -D 1 -N 5"
weka.attributeSelection.CfsSubsetEval \
-P 1 \
-E 1
Associators, like Apriori, can be run like this:
python weka/associators.py \
-t /my/datasets/iris.arff \
weka.associations.Apriori \
-N 9 -I