All problems
Accuracy
Problem
Compute classification accuracy: fraction of y_true[i] that equal y_pred[i]. Empty input returns 0.0.
Test cases
case 1
in: [[1,0,1,1],[1,0,0,1]]
expected: 0.75
case 2
in: [[1,1,1],[1,1,1]]
expected: 1
case 3
in: [[0,1,0],[1,0,1]]
expected: 0
case 4
in: [[],[]]
expected: 0
Starter codePython
def accuracy(y_true, y_pred):
# Your code here
pass4 test cases · run your code against them in the editor