Zeichnen eines Mosaikplots der Konfusionsmatrix
Das Berechnen der Leistungsmatrix mag zwar Spaß machen, aber es würde mühsam werden, wenn du mehrere Konfusionsmatrizen verschiedener Modelle benötigst. Zum Glück kann die .pred_table() Methode die Konfusionsmatrix für dich berechnen.
Außerdem kannst du die Ausgabe der Methode .pred_table() verwenden, um die Konfusionsmatrix mit der Funktion mosaic() zu visualisieren.
churn und mdl_churn_vs_relationship sind verfügbar.
Diese Übung ist Teil des Kurses
Einführung in die Regression mit statsmodels in Python
Anleitung zur Übung
- Importiere die Funktion
mosaic()vonstatsmodels.graphics.mosaicplot. - Erstelle
conf_matrixmit der Methode.pred_table()und drucke es aus. - Zeichne ein Mosaikdiagramm der Konfusionsmatrix.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# 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()