Skip to content
CampusEduX

Problem 1: Generate a Basic Confusion Matrix

Easypython
Learn the Concept: Confusion Matrix

Problem Description

Write a Python program that generates and prints a confusion matrix given actual and predicted labels for a binary classification problem.

Input

Two lists: actual labels and predicted labels.

Output

The confusion matrix.

Constraints

  • Both lists have the same length, containing binary values.

Example Input

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

Example Output

text
[[1 1] [1 2]]

Concepts Covered

confusion_matrix().

Related Problems

  • Problem 2: Visualize a Confusion Matrix as a Heatmap
    Easy · python
    Solve Problem
  • Problem 3: Extract TP, TN, FP, FN from a Confusion Matrix
    Easy · python
    Solve Problem
  • Problem 4: Build a Confusion Matrix for a 3-Class Problem
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...