Threshold Sweep Grid

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 binary true labels and predicted probability scores, sweep thresholds t ∈ {0.1, 0.2, …, 0.9} and for each compute precision, recall, and F1. Classify as positive if score >= t. Output one row per threshold.

Input

  • Line 1: integer n
  • Line 2: n space-separated ints (true labels: 0 or 1)
  • Line 3: n space-separated floats (predicted scores in [0, 1])

Output

9 lines, format: threshold precision recall f1

Example

Input:

5
1 0 1 1 0
0.9 0.2 0.8 0.6 0.4

Output:

0.1 0.6 1 0.75
0.2 0.6 1 0.75
0.3 0.6 1 0.75
0.4 0.6 1 0.75
0.5 0.6 1 0.75
0.6 0.6 1 0.75
0.7 1 0.6666666667 0.8
0.8 1 0.6666666667 0.8
0.9 1 0.3333333333 0.5

Scaffolding

def threshold_grid(labels: list[int], scores: list[float]) -> list[tuple]: ...

Notes

Track A: use NumPy vectorised comparisons. Studying this grid visualises the precision–recall tradeoff across the full threshold range.


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.