No subject
Davies, Bob
bdavies at intel.com
Wed Jan 2 23:23:02 CET 2002
Any rpart user:
I am trying to construct an rpart tree using a subset of the data and it
will occasionally fail when predicting a categorical response variable.
The reason that rpart fails is that the subset does not contain each of the
categories present in the original data. For example, in the car.test.frame
example, a subset that has all the categories except "Small" will not
produce an rpart tree.
I attempted to use "parms=list(prior=...) and it did not correct the
problem.
Here is a demonstration of the problem using the car.test.frame:
library(rpart)
data(car.test.frame)
t1 <- rpart(Type ~ ., car.test.frame)
t1
sub <- row.names(car.test.frame[car.test.frame[,"Weight"] > 2567.5,]) #
create a subset
rpart (Type ~ ., car.test.frame, subset=sub ) # this statement will fail
# so now attempt to indicate what the priors should look like:
rpart (Type ~ ., car.test.frame, subset=sub,
parms=list(prior=t1$parms$prior)) # this statement will fail
# now add 1 "Small" car to this subset of car.test.frame
sub <- row.names(car.test.frame[car.test.frame[,"Weight"] > 2559,]) # lower
the weight just a little to get a "Small" car.
rpart(Type ~ ., car.test.frame, subset=sub) # This statement will work !
Any suggestions?
I am using R 1.4.0 on Windows 2000.
Bob Davies
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list