Interview Query

Precision and Recall

0
Have you seen this question before?

Given a 2-D matrix P of predicted values and actual values, write a function precision_recall to calculate precision and recall metrics.

Return the ordered pair (precision, recall).

Example:

Input:

P = [[121, 9],
    [17, 144]]

where P represents the following table

Predicted =TRUE Predicted =FALSE
Actual =TRUE 121 9
Actual =FALSE 17 144

Output:

def precision_recall(P) -> (0.931, 0.877,)
Next question: Improve Search Results
.....
Python 3.9.6
Loading editor
Use Shift + Enter to run code