Skip to content
DeepForgeby svx
All problems
HardML Fundamentalsml-195

IPW ATE Estimate

Problem

Estimate the average treatment effect with inverse propensity weighting: mean(t*y/e - (1-t)*y/(1-e)), clipping propensities to [1e-6, 1 - 1e-6].

Empty input returns 0.0.

Hint

Each unit stands in for the population its propensity implies.

Test cases

case 1
in: [[1,1,0,0],[1,0,1,0],[0.5,0.5,0.5,0.5]]
expected: 0
case 2
in: [[1,1,0,0],[1,1,0,0],[0.5,0.5,0.5,0.5]]
expected: 1
case 3
in: [[1,0],[2,1],[0.8,0.5]]
expected: 0.25
case 4
in: [[],[],[]]
expected: 0
Starter codePython
def ipw_ate(treatment, outcome, propensity):
    # Your code here
    pass

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