LoslegenKostenlos loslegen

Ein Mosaikdiagramm der Confusion-Matrix zeichnen

Das Berechnen der Leistungskennzahlen macht vielleicht Spaß, aber es wird mühsam, wenn du mehrere Confusion-Matrizen für unterschiedliche Modelle benötigst. Zum Glück kann die Methode .pred_table() die Confusion-Matrix für dich berechnen.

Außerdem kannst du die Ausgabe von .pred_table() nutzen, um die Confusion-Matrix mit der Funktion mosaic() zu visualisieren.

churn und mdl_churn_vs_relationship sind verfügbar.

Diese Übung ist Teil des Kurses

Einführung in Regression mit statsmodels in Python

Kurs anzeigen

Anleitung zur Übung

  • Importiere die Funktion mosaic() aus statsmodels.graphics.mosaicplot.
  • Erstelle conf_matrix mit der Methode .pred_table() und gib sie aus.
  • Zeichne ein Mosaikdiagramm der Confusion-Matrix.

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()
Code bearbeiten und ausführen