Skip to content
C

Problem 4: Build a Confusion Matrix for a 3-Class Problem

Easypython

Problem Description

Write a Python program that generates and visualizes a confusion matrix for a 3-class classification problem.

Input

Actual and predicted labels with 3 possible classes (e.g., 0, 1, 2).

Output

The 3×3 confusion matrix, printed and visualized.

Constraints

  • Labels must include all 3 classes.

Example Input

text
actual=[0,1,2,0,1,2,0,1,2], predicted=[0,1,1,0,2,2,0,1,2]

Example Output

text
(A 3x3 confusion matrix, printed and displayed as a heatmap)

Concepts Covered

Multi-class confusion_matrix(), ConfusionMatrixDisplay.

Input (stdin)

Output

Run your code to see output here...