Question: In [ 5 3 ] : # Make predictions on the test data pred - predict ( pruned _ model, newdata = test.data 4 ,

In [53]: # Make predictions on the test data
pred - predict(pruned_model, newdata=test.data4, type='class')
# Construct the confusion matrix
conf.matrix - table(test.data3$default, pred)[,c('no', 'yes')]
rownames(conf.matrix)- paste("Actual default ", rownames(conf.matrix), sep =": ")
colnames(conf.matrix)- past("Prediction default ", colnames(conf.matrix), sep =": ")
# Print nicely formatted confusion matrix
print("Confusion Matrix")
format (conf.matrix, justify="centre", digit=2)
Error in predict.rpart(pruned_model, newdata = test.data4, type = "class"): Invalid prediction for "rpart" object
Traceback:
predict(pruned_model, newdata = test.data4, type = "class")
predict.rpart(pruned_model, newdata = test.data4, type = "class")
stop("Invalid prediction for "rpart" object")
 In [53]: # Make predictions on the test data pred -

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

Students Have Also Explored These Related Databases Questions!