Problem 2: Manually Calculate TP, TN, FP, FN
Easypython
Learn the Concept: Accuracy, Precision, Recall, F1-ScoreProblem 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
textactual=[1,0,1,1,0], predicted=[1,0,0,1,0]
Example Output
textTP: 2, TN: 2, FP: 0, FN: 1
Concepts Covered
Loops, conditionals, manual counting.
Related Problems
- Problem 1: Calculate All Four MetricsEasy · pythonSolve Problem
- Problem 3: Compare Precision and Recall on an Imbalanced DatasetEasy · pythonSolve Problem
- Problem 4: Calculate F1-Score ManuallyEasy · pythonSolve Problem