All problems
Counterfactual Cost
Problem
Compute the L1 cost of a counterfactual explanation: the sum of absolute differences between the query point and the counterfactual.
Hint
Smaller distance means the explanation is easier to act on.
Test cases
case 1
in: [[1,2],[2,0]]
expected: 3
case 2
in: [[5,5],[5,5]]
expected: 0
case 3
in: [[],[]]
expected: 0
Starter codePython
def counterfactual_cost(x, c):
# Your code here
pass3 test cases · run your code against them in the editor