All problems
Grid Search Best Params
Problem
Search a parameter grid and return the parameter set with the highest score.
params_list is a list of parameter dicts and scores holds the parallel scores; ties keep the earliest entry. Empty input returns {}.
Hint
Track the best index with a strict greater-than so ties keep the first candidate.
Test cases
case 1
in: [[{"lr":0.1,"depth":2},{"lr":0.01,"depth":3},{"lr":0.1,"depth":3}],[0.8,0.9,0.85]]
expected: {"lr":0.01,"depth":3}
case 2
in: [[{"a":1},{"a":2}],[0.7,0.7]]
expected: {"a":1}
case 3
in: [[{"x":"only"}],[0.5]]
expected: {"x":"only"}
case 4
in: [[],[]]
expected: {}
Starter codePython
def grid_search_best(params_list, scores):
# Your code here
pass4 test cases · run your code against them in the editor