All problems
T-Learner Effect
Problem
Return the T-learner CATE at x: (m1_intercept + m1_slope*x) - (m0_intercept + m0_slope*x), where each arm has its own linear model. Return 0.0 when either coefficient list does not have exactly two entries (intercept, slope).
Hint
Each arm extrapolates its own regression to x.
Test cases
case 1
in: [2,[1,3],[0.5,1]]
expected: 4.5
case 2
in: [0,[2,1],[1,1]]
expected: 1
case 3
in: [-1,[1,2],[3,1]]
expected: -3
case 4
in: [1,[1],[1,0]]
expected: 0
Starter codePython
def t_learner_effect(x, treated_coefficients, control_coefficients):
# Your code here
pass4 test cases · run your code against them in the editor