Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-041

Sensitivity and Specificity from Counts

Problem

Return [sensitivity, specificity] from counts: sensitivity = tp / (tp + fn) and specificity = tn / (tn + fp). Return 0.0 for a ratio whose denominator is zero.

Hint

Each measure is a conditional proportion in one row of the confusion matrix.

Test cases

case 1
in: [90,10,80,20]
expected: [0.9,0.8]
case 2
in: [50,0,50,0]
expected: [1,1]
case 3
in: [0,10,20,0]
expected: [0,1]
case 4
in: [0,0,0,0]
expected: [0,0]
case 5
in: [40,10,45,5]
expected: [0.8,0.9]
Starter codePython
def sensitivity_specificity(tp, fn, tn, fp):
    # Your code here
    pass

5 test cases · run your code against them in the editor