[R] Corrupt trees

From: Osei Poku <opoku_at_ece.cmu.edu>
Date: Wed, 23 Mar 2011 14:29:15 -0400

Hi Everyone,

I have been using the "tree" package for a while with no problems until now.

When I run predict(tree, newdata), I get an error with the message "Corrupt tree" for about 50% of the trees that I generate with tree. For other trees, the predict function completes with no errors.

I haven't identified a correlation between the corrupt trees and the working tree. It is the same code with the same data set. The only difference is that the training data is sampled randomly from the complete data set.

The "copy-pasted" code below illustrates:

> data <- load.data()
> mytree <- run.tree(data)
> mypred <- gen.predictions(mytree, data )

Error in pred1.tree(object, tree.matrix(newdata)) : corrupt tree                                                                                                                  

> mytree <- run.tree(data)
> mypred <- gen.predictions(mytree,data )
 (no error here)

The function run.tree() does the following:

1. Split the data into training and test
2. Call tree() to generate a tree object
3. Returns the indices of the training, test in the data as well as the tree object

The function gen.predictions() does the following: 1. Call predict() with the tree object from run.tree() and the test data 2. Returns the yprob values and other information about the predictions

Any help would be greatly appreciated.


R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 23 Mar 2011 - 18:50:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Mar 2011 - 19:00:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive