All problems
Residuals
Problem
Compute the residuals y_true - y_pred element-wise.
Return the list of residuals; empty input returns [].
Hint
Subtract each prediction from the corresponding true value.
Test cases
case 1
in: [[3,5,7],[2,4,9]]
expected: [1,1,-2]
case 2
in: [[1,2,3],[1,2,3]]
expected: [0,0,0]
case 3
in: [[-1,-2],[1,2]]
expected: [-2,-4]
case 4
in: [[],[]]
expected: []
Starter codePython
def residuals(y_true, y_pred):
# Your code here
pass4 test cases · run your code against them in the editor