Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-234

Decile Response Rate

Problem

Compute the response rate per decile. Sort by score descending (ties by original index) and split into min(10, n) equal contiguous chunks.

Return the mean label of each chunk; empty input returns [].

Hint

Response rates should generally decline across ranked deciles for a useful model.

Test cases

case 1
in: [[1,0,1,0,1,0,1,0,1,0],[0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1,0]]
expected: [1,0,1,0,1,0,1,0,1,0]
case 2
in: [[1,1,1,1,0,0,0,0],[0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1]]
expected: [1,1,1,1,0,0,0,0]
case 3
in: [[1,0,1],[0.9,0.5,0.1]]
expected: [1,0,1]
case 4
in: [[],[]]
expected: []
Starter codePython
def decile_response_rate(y_true, scores):
    # Your code here
    pass

4 test cases · run your code against them in the editor