[R] QUestion on prediction of class from rpart

From: Kamakshi <laksh004_at_tc.umn.edu>
Date: Fri 11 Aug 2006 - 05:10:08 EST


I am trying to predict the classes of a test data set after training an rpart tree.
When I run:
predict(rpart_object_based_on_training_data, newdata = "testdata", type = "class", na.action = na.pass)
I get an error message saying that a variable that is present in both training and test data sets has new
levels in the test set. This is true that there are new levels for some of the variables in the test set, although, the variables themselves are identical in both. My understanding from reading the documentation on
predict.rpart is that if one of the facor-variables does have new levels in the test set, it is passed through the tree and is left at the deepest possible node. I tried to run predict.rpart directly but it says "function not found". Does this have to be installed separately? I have loaded the rpart library to run the training data. I have not
found this exact situation in the Archives.



R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri Aug 11 06:21:10 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 11 Aug 2006 - 08:21:44 EST.

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