1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Regression with statsmodels in Python

Exercise

Drawing a mosaic plot of the confusion matrix

While calculating the performance matrix might be fun, it would become tedious if you needed multiple confusion matrices of different models. Luckily, the .pred_table() method can calculate the confusion matrix for you.

Additionally, you can use the output from the .pred_table() method to visualize the confusion matrix, using the mosaic() function.

churn and mdl_churn_vs_relationship are available.

Instructions

100 XP
  • Import the mosaic() function from statsmodels.graphics.mosaicplot.
  • Create conf_matrix using the .pred_table() method and print it.
  • Draw a mosaic plot of the confusion matrix.