All problems
Interaction H-Statistic
Problem
Compute the Friedman H-statistic for a feature pair: sqrt(sum((pdp_jk - pdp_j - pdp_k)^2) / sum(pdp_jk^2)).
Return 0.0 when the denominator is 0.
Hint
The H-statistic measures how much the joint partial dependence deviates from additivity.
Test cases
case 1
in: [[[2,3],[3,4]],[1,2],[1,2]]
expected: 0
case 2
in: [[[2,3],[4,5]],[1,2],[1,2]]
expected: 0.19245008972987526
case 3
in: [[[0,0],[0,0]],[0,0],[0,0]]
expected: 0
Starter codePython
def interaction_h_statistic(pdp_jk, pdp_j, pdp_k):
# Your code here
pass3 test cases · run your code against them in the editor