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.
Deze oefening maakt deel uit van de cursus
Introduction to Regression with statsmodels in Python
Oefeninstructies
- Import the
mosaic()function fromstatsmodels.graphics.mosaicplot. - Create
conf_matrixusing the.pred_table()method and print it. - Draw a mosaic plot of the confusion matrix.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Import mosaic from statsmodels.graphics.mosaicplot
____
# Calculate the confusion matrix conf_matrix
conf_matrix = ____
# Print it
print(conf_matrix)
# Draw a mosaic plot of conf_matrix
____
plt.show()