Search code examples
rwekadecision-tree

Can I manually create an RWeka decision (Recursive Partitioning) tree?


I have constructed a J48 decision tree using RWeka. I would like to compare its performance to a decision tree described an existing (externally computed) decision tree. I'm new to RWeka and I'm having trouble manually creating an RWeka decision tree. Ideally, I would like to show the two side-by-side and plot them using the RWeka visualization (It is very informative and clean).

Right now, I'm going to export the RWeka computed decision tree to Graphviz and manipulate it into the structure I want. I want to check before I start and make sure I cant simply specify the rules I want to manually specify a decision tree.

I don't want to compute the decision tree (I've done that), I want to manually construct/specify a decision tree (for uniform comparison in my presentation).

Thank you in advanced.


Solution

  • The RWeka package itself cannot do that . However, RWeka uses the partykit package for displaying its trees which can do what you want. Look at the vignette(“partykit“, package = “partykit“) how you can construct a recursive partynode object with pre-specified partysplits and then turn them into a constparty. The vignette has a hands-on example for this.