Skip to content

Commit

Permalink
measure fscore besides precision n recall
Browse files Browse the repository at this point in the history
Former-commit-id: 73c9fcb10a827e5e5a31e8ec2e196327c89db30d
  • Loading branch information
Javi Ribera committed Apr 9, 2018
1 parent 00d824f commit e6bbf2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion object-locator/eval_precision_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def evaluate_sample(self, pts, gt):
def get_p_n_r(self):
precision = 100*self.tp / (self.tp + self.fp)
recall = 100*self.tp / (self.tp + self.fn)
fscore = 2 * (precision*recall/(precision+recall))

return precision, recall
return precision, recall, fscore


#tests
Expand Down
11 changes: 6 additions & 5 deletions object-locator/locate.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,19 @@

# Output CSV where we will put
# the precision as a function of r
df_prec_n_rec = pd.DataFrame(columns=['precision', 'recall'])
df_prec_n_rec = pd.DataFrame(columns=['precision', 'recall', 'fscore'])
df_prec_n_rec.index.name = 'r'

print(f'\__ Average AHD for all the testing set: {avg_ahd:.3f}')
print('\__ Accuracy for all the testing set, r=0, ..., 15')
for judge in judges:
prec, rec = judge.get_p_n_r()
print(f'r={judge.r} => Precision: {prec:.3f}, Recall: {rec:.3f}')
prec, rec, fscore = judge.get_p_n_r()
print(f'r={judge.r} => Precision: {prec:.3f}, Recall: {rec:.3f}, F-score: {fscore:.3f}')

# Accumulate precision and recall in the CSV dataframe
df = pd.DataFrame(data=[[prec, rec]],
df = pd.DataFrame(data=[[prec, rec, fscore]],
index=[judge.r],
columns=['precision', 'recall'])
columns=['precision', 'recall', 'fscore'])
df.index.name = 'r'
df_prec_n_rec = df_prec_n_rec.append(df)
print(f'\__ MAPE for all the testing set: {mape:.3f} %')
Expand All @@ -309,3 +309,4 @@
# Write CSV to disk
df_out.to_csv(os.path.join(args.out_dir, 'estimations.csv'))
df_prec_n_rec.to_csv(os.path.join(args.out_dir, 'precision_and_recall.csv'))

0 comments on commit e6bbf2f

Please sign in to comment.