Code RoomConfidence calibration buckets
MediumPrep Room Coding #538

Confidence calibration buckets

CodingML systemsEntry–Mid~15 min

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.

Implement
calibration_counts(scores: list[int], labels: list[int]) → list[list[int]]
Examples
in[[5,95,42,100],[0,1,1,1]]out[[1,0],[0,0],[0,0],[0,0],[1,1],[0,0],[0,0],[0,0],[0,0],[2,2]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 15 min
InputExpectedGot
[[5,95,42,100],[0,1,1,1]][[1,0],[0,0],[0,0],[0,0],[1,1],[0,0],[0,0],[0,0],[0,0],[2,2]]not run yetsample