Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set.seed(15)
- train.data <- final_data_Fpositive[sample(358,215),]
- set.seed(15)
- test.data <- final_data_Fpositive[-sample(358,215),]
- CLtree <- rpart(TB~., data = train.data, method = "class")
- plot(CLtree)
- text(CLtree, pretty = 0)
- printcp(CLtree)
- plotcp(CLtree)
- ptree<- prune(CLtree, cp= CLtree$cptable[which.min(CLtree$cptable[,"xerror"]),"CP"])
- plot(ptree, uniform=TRUE, main="Pruned Classification Tree")
- text(ptree, cex = 0.7)
- pred.pruned <- predict(ptree, test.data, "class")
- mean(pred.pruned == test.data$TB)
- table(test.data$TB,pred.pruned)
Add Comment
Please, Sign In to add comment