Question: ```{r} ensemble = read.csv(C:/Users/zeedu/Downloads/Loan Approval Prediction- train_cleaned.csv) library(car) #ensemble$LoanStatus = as.factor(ensemble$LoanStatus) #partition the data with 7:3 ratio #list: we give TRUE for the results to

```{r} ensemble = read.csv("C:/Users/zeedu/Downloads/Loan Approval Prediction- train_cleaned.csv") library(car) #ensemble$LoanStatus = as.factor(ensemble$LoanStatus) #partition the data with 7:3 ratio #list: we give "TRUE" for the results to be in a list library(caret) set.seed(123) partition = createDataPartition(ensemble$LoanStatus, p=0.7, list=FALSE) train.df = ensemble[partition,] test.df = ensemble[-partition,] trainLabel = ensemble[partition,11] testLabel = ensemble[-partition,11] library(rpart) library(rpart.plot) cartModel = rpart(LoanStatus~., data = train.df, method = "class") plot(cartModel) text(cartModel) rpart.plot(cartModel) summary(cartModel) printcp(cartModel) plotcp(cartModel) #the CP with the lowest xerror is 0.010000 new = test.df[1:10, -11] pruning = prune(cartModel, cp=0.010000, "CP") predict(pruning, newdata = new, type ="class") rpart.plot(pruning, cex=0.7) cartpred = predict(cartModel, test.df, type = "class") confusionMatrix(cartpred, testLabel) ```

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock