Confidence calibration buckets

Write codeMedium15 minAnthropic and OpenAI style

Your task

To check whether a churn model's confidence scores are calibrated, the eval groups predictions into ten confidence buckets and counts outcomes per bucket. Given equal-length lists scores (integers 0-100) and labels (0 or 1), assign each prediction to bucket floor(score / 10), except that a score of 100 goes into bucket 9. Return a list of exactly 10 rows, where row i is [count of predictions in bucket i, count of those with label 1]. Example: scores = [5, 95, 42, 100], labels = [0, 1, 1, 1] puts 5 in bucket 0, 42 in bucket 4, and 95 and 100 in bucket 9.

Examples

calibration_counts(scores: list[int], labels: list[int]) -> list[list[int]]
Example 1
Inputcalibration_counts([5, 95, 42, 100], [0, 1, 1, 1])
Output[[1, 0], [0, 0], [0, 0], [0, 0], [1, 1], [0, 0], [0, 0], [0, 0], [0, 0], [2, 2]]