All problems
Model Confidence Set Trim
Problem
Trim a set of models to a confidence set. Compute each model's mean loss, then return the indices of the `keep` models with the smallest means, sorted in ascending index order.
Return an empty list for empty input or keep <= 0.
Hint
Ties are broken by original index because the sort key includes it.
Test cases
case 1
in: [[[1,1],[2,2],[3,3]],2]
expected: [0,1]
case 2
in: [[[5],[1],[3]],1]
expected: [1]
case 3
in: [[[1,1],[1,1]],2]
expected: [0,1]
case 4
in: [[],1]
expected: []
Starter codePython
def model_confidence_set_trim(losses, keep):
# Your code here
pass4 test cases · run your code against them in the editor