BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Introduction to Regression with statsmodels in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • 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.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# 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()
Kodu Düzenle ve Çalıştır