0

I have a conditional inference tree model (ctree) saved in an R .rda file and am trying to convert it into a Weka .arff file:

library("foreign")

load("my_ctree.rda")
write.arff(my_ctree, file = "outputFile.arff")

but I get error:

Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ‘structure("BinaryTree", package = "party")’ to a data.frame

How can I achieve this?

Javide
  • 2,477
  • 5
  • 45
  • 61
  • Are you using the partykit package? (I'm guessing.) If so, the result of the ctree function is a party object which is itself not a data.frame but a more complex data structure. – KirkD-CO Oct 17 '18 at 03:46
  • Yes, I'm using the `party` package. Does it mean there is not a function already available to perform this conversion? – Javide Oct 17 '18 at 03:47
  • Do you know what a binary tree is? – IRTFM Oct 17 '18 at 05:33
  • 1
    I'm not sure what you're trying to do, but the .arff file is a data file format for Weka and ctree is a structure that results from trading a binary tree ground the party package. Are you trying to import the binary tree into Weka? I don't know if that's possible. – KirkD-CO Oct 17 '18 at 11:43
  • trading should be training – KirkD-CO Oct 17 '18 at 11:44
  • Yes, I’m trying to import the binary tree trained from the the R party package into the Java Weka library. – Javide Oct 17 '18 at 11:50
  • As @KirkD-CO says the [ARFF format](https://waikato.github.io/weka-wiki/arff_stable/) is for datasets, not models. What do you want to do with the tree in Weka - evaluate its performance using Weka? use it to make predictions on a new dataset? Maybe you want to use [RPlugin](http://weka.sourceforge.net/packageMetaData/RPlugin/index.html)? – nekomatic Oct 18 '18 at 15:41

0 Answers0