All problems
Precision from Counts
Problem
Precision is the fraction of predicted positives that are correct: TP / (TP + FP). Return 0.0 when the denominator is zero.
Given the counts, return the precision.
Hint
It answers: of the alarms raised, how many were real?
Test cases
case 1
in: [8,2]
expected: 0.8
case 2
in: [0,5]
expected: 0
case 3
in: [3,0]
expected: 1
Starter codePython
def precision_from_counts(tp, fp):
# Your code here
pass3 test cases · run your code against them in the editor