Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-293

R-Learner Pseudo-Outcome

Problem

Compute R-learner pseudo-outcomes: (y - m) / (t - e), clipping the treatment-minus-propensity denominator to at least 1e-6 in magnitude with its original sign.

Empty input returns [].

Hint

The pseudo-outcome regresses the residualized outcome on the residualized treatment.

Test cases

case 1
in: [[2,4,6],[1,2,3],[1,1,0],[0.5,0.5,0.5]]
expected: [2,4,-6]
case 2
in: [[5],[1],[1],[0.5]]
expected: [8]
case 3
in: [[3],[1],[1],[1]]
expected: [2000000]
Starter codePython
def r_learner_pseudo(y, m, treatment, propensity):
    # Your code here
    pass

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