1.1. Exercises

Name That Value!

404 image

True or False: Confusion Matrix

Code a Confusion Matrix

Instructions:
Running a coding exercise for the first time could take a bit of time for everything to load. Be patient, it could take a few minutes.

When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.

Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line won’t execute and you can test your code after each step.

We’ve seen our basketball dataset before and predicted using SVC with it before but this time we are going to have a look at how well our model does by building a confusion matrix.

Tasks:

  • Build a pipeline named pipe_bb that preprocesses with preprocessor and builds an SVC() model with default hyperparameters.
  • Fit the pipeline on X_train and y_train.
  • Next, build a confusion matrix using plot_confusion_matrix and calling pipe_bb on the test set. Pick any colour you like with cmap. You can find the colour options here.
Hint 1
  • Are you using make_pipeline(preprocessor, SVC())?
  • Are you fitting your model?
  • Are you calling pipe_bb, X_test and y_test in the ConfusionMatrixDisplay.from_estimator() function?
Fully worked solution: