Commit
•
0bb4395
1
Parent(s):
b53c8ac
Reinstate PR curve sentinel values (#1645)
Browse files- utils/metrics.py +6 -7
utils/metrics.py
CHANGED
@@ -77,18 +77,17 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, save_dir='precision
|
|
77 |
|
78 |
|
79 |
def compute_ap(recall, precision):
|
80 |
-
""" Compute the average precision, given the recall and precision curves
|
81 |
-
Source: https://github.com/rbgirshick/py-faster-rcnn.
|
82 |
# Arguments
|
83 |
-
recall: The recall curve (list)
|
84 |
-
precision: The precision curve (list)
|
85 |
# Returns
|
86 |
-
|
87 |
"""
|
88 |
|
89 |
# Append sentinel values to beginning and end
|
90 |
-
mrec =
|
91 |
-
mpre =
|
92 |
|
93 |
# Compute the precision envelope
|
94 |
mpre = np.flip(np.maximum.accumulate(np.flip(mpre)))
|
|
|
77 |
|
78 |
|
79 |
def compute_ap(recall, precision):
|
80 |
+
""" Compute the average precision, given the recall and precision curves
|
|
|
81 |
# Arguments
|
82 |
+
recall: The recall curve (list)
|
83 |
+
precision: The precision curve (list)
|
84 |
# Returns
|
85 |
+
Average precision, precision curve, recall curve
|
86 |
"""
|
87 |
|
88 |
# Append sentinel values to beginning and end
|
89 |
+
mrec = np.concatenate(([0.], recall, [recall[-1] + 0.01]))
|
90 |
+
mpre = np.concatenate(([1.], precision, [0.]))
|
91 |
|
92 |
# Compute the precision envelope
|
93 |
mpre = np.flip(np.maximum.accumulate(np.flip(mpre)))
|