Skip to content
CampusEduX

Problem 2: Manually Calculate TP, TN, FP, FN

Easypython
Learn the Concept: Accuracy, Precision, Recall, F1-Score

Problem Description

Write a Python program that manually counts True Positives, True Negatives, False Positives, and False Negatives given actual and predicted labels, without using any built-in function.

Input

Two lists: actual labels and predicted labels.

Output

The counts of TP, TN, FP, and FN.

Constraints

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

Example Input

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

Example Output

text
TP: 2, TN: 2, FP: 0, FN: 1

Concepts Covered

Loops, conditionals, manual counting.

Related Problems

  • Problem 1: Calculate All Four Metrics
    Easy · python
    Solve Problem
  • Problem 3: Compare Precision and Recall on an Imbalanced Dataset
    Easy · python
    Solve Problem
  • Problem 4: Calculate F1-Score Manually
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...