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.
Latihan ini adalah bagian dari kursus
Introduction to Regression with statsmodels in Python
Petunjuk latihan
- 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.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# 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()