Precision Score
MediumMachine LearningArray
Description
Given equal-length binary arrays yTrue and yPred (1 = positive), return precision = TP / (TP + FP), rounded to 4 decimal places. If there are no predicted positives, return 0.
Examples
Input:
yTrue = [1,0,1,1], yPred = [1,1,1,0]Output:
0.6667Explanation:
Of all positive predictions, the fraction that were correct is 0.6667.
Input:
yTrue = [1,1,0], yPred = [1,1,1]Output:
0.6667Explanation:
Of all positive predictions, the fraction that were correct is 0.6667.
Input:
yTrue = [0,0], yPred = [0,0]Output:
0Explanation:
Of all positive predictions, the fraction that were correct is 0.
Constraints
- •
1 ≤ yTrue.length ≤ 10⁴ - •
values are 0 or 1