Confusion Matrix Scores
Xem dạng PDF
Gửi bài giải
Điểm:
100,00
Giới hạn thời gian:
2.0s
Giới hạn bộ nhớ:
256M
Tác giả:
Dạng bài
Ngôn ngữ cho phép
Python
Task
Given n true binary labels and n predicted binary labels, compute precision, recall, and F1 score.
If TP + FP = 0, precision = 0. If TP + FN = 0, recall = 0. If both are 0, F1 = 0.
Input
- Line 1: integer
n - Line 2:
nspace-separated ints (true labels: 0 or 1) - Line 3:
nspace-separated ints (predicted labels: 0 or 1)
Output
Three space-separated floats: precision recall f1
Example
Input:
6
1 0 1 1 0 0
1 1 1 0 0 0
Output:
0.6666666667 0.6666666667 0.6666666667
Scaffolding
def confusion_matrix_score(y_true: list[int], y_pred: list[int]) -> tuple: ...
Notes
Track A: use NumPy boolean indexing. Precision = TP / (TP+FP); Recall = TP / (TP+FN); F1 = 2·P·R / (P+R).
Bình luận