Session Ready
Exercise

Prediction and confusion matrix

As you saw in the video, a confusion matrix is a very useful tool for examining all possible outcomes of your predictions (true positive, true negative, false positive, false negative).

In this exercise, you will predict those who will default using bagged trees. You will also create the confusion matrix using the confusionMatrix() function from the caret package.

It's always good to take a look at the output using the print() function.

Instructions
100 XP

The fitted model object, credit_model, is already in your workspace.

  • Use the predict() function with type = "class" to generate predicted labels on the credit_test dataset.
  • Take a look at the prediction using the print() function.
  • Calculate the confusion matrix using the confusionMatrix function.