Skip to content
CampusEduX

Problem 1: Calculate All Four Metrics

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

Problem Description

Write a Python program that calculates Accuracy, Precision, Recall, and F1-Score for a given set of actual and predicted labels using Scikit-learn.

Input

Two lists: actual labels and predicted labels.

Output

All four calculated metrics.

Constraints

  • Both lists must have the same length, containing binary (0/1) values.

Example Input

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

Example Output

text
Accuracy: 0.8 Precision: 1.0 Recall: 0.67 F1-Score: 0.8

Concepts Covered

accuracy_score(), precision_score(), recall_score(), f1_score().

Related Problems

  • Problem 2: Manually Calculate TP, TN, FP, FN
    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...