O'Reilly logo

R Statistical Application Development by Example Beginner's Guide by Prabhanjan Narayanachar Tattar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – pruning a classification tree

A CART is improved by using minsplit and cp arguments in the rpart function.

  1. Invoke the graphics editor with par(mfrow=c(1,2)).
  2. Specify minsplit=30, and re-do the ROC plots by using the new classification tree:
    GC_rpart_minsplit<- rpart(good_bad~.,data=GC_Train, minsplit=30) GC_rpart_minsplit <- prune(GC_rpart,cp=0.05) Pred_Train_Class<- predict(GC_rpart_minsplit,type='class') Pred_Train_Prob<-predict(GC_rpart_minsplit,type='prob') Train_Pred<- prediction(Pred_Train_Prob[,2],GC_Train$good_bad) Perf_Train<- performance(Train_Pred,»tpr»,»fpr») plot(Perf_Train,col=»green»,lty=2) Pred_Validate_Class<-predict(GC_rpart_minsplit,newdata=GC_Validate[,-21],type='class') Pred_Validate_Prob<-predict(GC_rpart_minsplit,newdata= ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required