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

In [24]:
# Make predictions on the test data
pred - predict(pruned_model1, newdata=test.data1, type='class')
# Construct the confusion matrix
conf.matrix - table(test.data1$default, pred)[,c('no', 'yes')]
rownames(conf.matrix)- paste("Actual default ", rownames(conf.matrix), sep =": ")
colnames(conf.matrix)- paste("Prediction default ", colnames(conf.matrix), sep =": ")
# Print nicely formatted confusion matrix
print("Confusion Matrix")
format (conf.matrix, justify="centre", digit=2)
Error in eval(predvars, data, env): object 'economy' not found
Traceback:
predict(pruned_model1, newdata = test.data1, type = "class")
predict.rpart(pruned_model1, newdata = test.data1, type = "class")
model.frame(Terms, newdata, na.action = na.action, xlev = attr(object,
"xlevels"))
model.frame.default(Terms, newdata, na.action = na.action, xlev = attr(object,
"xlevels"))
eval(predvars, data, env)
eval(predvars, data, env)
 In [24]: # 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!