Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-290

Uplift Cumulative Gain

Problem

Compute the uplift cumulative gain curve: after sorting by predicted uplift descending (ties by index), value_k = cum_treated_positives/n_treated - cum_control_positives/n_control.

Return [] when the input is empty or a treatment group is missing.

Hint

The curve should rise early when uplift scores rank responsive units first.

Test cases

case 1
in: [[1,1,0,0],[1,0,1,0],[0.9,0.8,0.2,0.1]]
expected: [0.5,0.5,0,0]
case 2
in: [[1,1,0,0],[1,0,1,0],[0.1,0.2,0.8,0.9]]
expected: [0,-0.5,-0.5,0]
case 3
in: [[1,0],[1,0],[0.5,0.5]]
expected: [1,1]
Starter codePython
def uplift_cumulative_gain(treatment, outcome, uplift_scores):
    # Your code here
    pass

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