Skip to content

xerror and xstd are missing from cptable of the Rpart package

2 messages · Kim C., Adams, Jean

#
Hello all, 
I'm making a decision tree with the rpart package. I want to prune the tree and in many tutorials it says to use cptable. Like so: opt <- which.min(model_rpart$cptable[, "xerror"])
The problem is that when I look up model_rpart$cptable it only show the columns CP, nsplit, rel error. So xerror and xstd are missing. How can this be? 
Model looks like this: model <- rpart(Product~. , data=trainData, control=rpart.control(minsplit=50, cp=0.002, xval=0))

Thank you. 
Kim
#
Kim,

The "x" in "xerror" and "xstd" stands for cross validation.  But you have
specified no cross validations, xval=0.

Try:

model <- rpart(Product ~ ., data=trainData, control=rpart.control(minsplit=50,
cp=0.002))
model$cptable

Jean
On Tue, Feb 3, 2015 at 7:09 AM, Kim C. <minorthreatx at hotmail.com> wrote: