Gil-Simas commited on
Commit
15c947d
·
verified ·
1 Parent(s): 7722807

add rec and precision

Browse files
Files changed (1) hide show
  1. horizon-metrics.py +12 -1
horizon-metrics.py CHANGED
@@ -180,11 +180,20 @@ class HorizonMetrics(evaluate.Metric):
180
  Returns:
181
  float: The computed horizon error.
182
  """
183
-
 
 
184
  # calculate erros and store values in slope_error_list and midpoint_error_list
185
  for annotated_horizon, proposed_horizon in zip(self.ground_truth_det,
186
  self.predictions):
187
 
 
 
 
 
 
 
 
188
  if annotated_horizon is None or proposed_horizon is None:
189
  continue
190
  slope_error, midpoint_error = calculate_horizon_error(
@@ -207,6 +216,8 @@ class HorizonMetrics(evaluate.Metric):
207
  detection_rate = detected_horizon_count / detected_gt_count
208
  result['detection_rate'] = detection_rate
209
  result['predicted_samples'] = detected_horizon_count
 
 
210
  result['samples'] = detected_gt_count
211
 
212
  return result
 
180
  Returns:
181
  float: The computed horizon error.
182
  """
183
+ tp = 0
184
+ fp = 0
185
+ fn = 0
186
  # calculate erros and store values in slope_error_list and midpoint_error_list
187
  for annotated_horizon, proposed_horizon in zip(self.ground_truth_det,
188
  self.predictions):
189
 
190
+ if annotated_horizon is None and proposed_horizon != None:
191
+ fp += 1
192
+ elif annotated_horizon != None and proposed_horizon != None:
193
+ tp += 1
194
+ elif annotated_horizon != None and proposed_horizon is None:
195
+ fn += 1
196
+
197
  if annotated_horizon is None or proposed_horizon is None:
198
  continue
199
  slope_error, midpoint_error = calculate_horizon_error(
 
216
  detection_rate = detected_horizon_count / detected_gt_count
217
  result['detection_rate'] = detection_rate
218
  result['predicted_samples'] = detected_horizon_count
219
+ result['recall'] = tp/(tp+fn+1e-5)
220
+ result['precision'] = tp/(fp+fn+1e-5)
221
  result['samples'] = detected_gt_count
222
 
223
  return result