0
$\begingroup$

I'm not sure if this is more appropriate for SO or DS in Stack Exchange since technically it's not about coding: in caret package for training in R, it's possible to train the model using rpart or rpart2 as the method.

I understand that rpart is an implementation of CART. What is rpart2 and how is it different from rpart?

My eventual aim is actually to compare the difference between the tree generated by rpart and rpart2, because my result seems to imply rpart2 has better accuracy for my dataset, but I have no clue how to view the rpart2 tree.

$\endgroup$
3
$\begingroup$

Both rpart and rpart2 implement a CART and wrap the rpart function from the rpart library. The difference is the constraints on the model each enforces. rpart uses the complexity parameter, cp, while rpart2 uses the max tree depth, maxdepth.

See: train_model_list section of http://cran.r-project.org/web/packages/caret/caret.pdf and rpart.control section of http://cran.r-project.org/web/packages/rpart/rpart.pdf.

$\endgroup$
1
  • $\begingroup$ Thanks. I belatedly found out also that the answer to the portion "but I have no clue how to view the rpart2 tree." is to view the finalModel element in the output of rpart2 trained with caret. $\endgroup$ – Ricky Jun 11 '15 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.