Search code examples
command-lineweka

Running multiple custom packages from Weka command line


I'm running WEKA from the unix command line. I want to encase an alternating decision tree (ADTree) within a Rotation Forest, two packages that are not part of the standard Weka 3.7 package.

Per http://weka.wikispaces.com/How+do+I+use+the+package+manager%3F, I understand that to call non-standard packages, (after first loading them using the package manager) I should envoke the weka.Run command. If I want to envoke ADTree, on the labor dataset that comes with Weka, I can do so with the following code:

java -cp weka/weka.jar weka.Run ADTree -t weka/data/labor.arff

Similarly, if I want to envoke a Rotation Forest, this code works:

java -cp weka/weka.jar weka.Run RotationForest -t weka/data/labor.arff

However, I'm not sure how to wrap the two algorithms together.

I can, say, wrap J48 in RotationForest:

java -cp weka/weka.jar weka.Run RotationForest -t weka/data/labor.arff -W weka.classifiers.trees.J48

But I'm not sure how to call ADTree after calling Rotation Forest. Neither of the following work:

java -cp weka/weka.jar weka.Run RotationForest -t weka/data/labor.arff weka.Run ADTree

java -cp weka/weka.jar weka.Run RotationForest -t weka/data/labor.arff -W weka.Run ADTree

java -cp weka/weka.jar weka.Run RotationForest -t weka/data/labor.arff -W weka.classifiers.trees.ADTree

Can someone please point out what I'm doing wrong?


Solution

  • Sheepishly, I continued my Googling and found the solution here: http://forums.pentaho.com/showthread.php?152334-WEKA-RotationForest-by-comman-line-is-not-working!

    Basically, I needed to start my syntax with:

    java -cp wekafiles/packages/alternatingDecisionTrees/alternatingDecisionTrees.jar:wekafiles/packages/rotationForest/rotationForest.jar:weka/weka.jar

    or

    java -cp [path-to-package_1] : [path-to-package_2] : [path-to-weka.jar]

    Then, I can envoke weka.classifiers.meta.rotationForest and weka.classifiers.trees.ADTree and go forward:

    java -cp wekafiles/packages/alternatingDecisionTrees/alternatingDecisionTrees.jar:wekafiles/packages/rotationForest/rotationForest.jar:weka/weka.jar weka.classifiers.meta.rotationForest -t weka/data/labor.arff -W weka.classifiers.trees.ADTree

    I'll leave this post open in case someone else might find it helpful.