Supervised Learning in R: Classification
Brett Lantz
Instructor
# pre-pruning with rpart
library(rpart)
prune_control <- rpart.control(maxdepth = 30, minsplit = 20)
m <- rpart(repaid ~ credit_score + request_amt,
data = loans,
method = "class",
control = prune_control)
# post-pruning with rpart
m <- rpart(repaid ~ credit_score + request_amt,
data = loans,
method = "class")
plotcp(m)
m_pruned <- prune(m, cp = 0.20)
Supervised Learning in R: Classification