Skip to content

Commit

Permalink
Adding statistics.py to compute our model score easily and with more …
Browse files Browse the repository at this point in the history
…clarity
  • Loading branch information
IMCoins committed Oct 4, 2018
1 parent df9f8c6 commit 55f3470
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions statistics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
def positive_image_stats(objs_found, nb_objs):
""" Update our general positive image stats.
Args:
objs_found : int
Number of objects found in image.
nb_objs : int
Total number of objects in image.
Returns:
tuple: (true_pos, false_neg, true_neg, false_pos)
"""
true_pos = 0
false_neg = 0
false_pos = 0

# If our match is correct, just set the true_pos value.
if objs_found == nb_objs:
true_pos += objs_found
else:

# Otherwise...
# If the number of objects found is superior, the excedents are false positives...
# Else... the excedents are false_negatives.
diff = nb_objs - objs_found
if diff > 0:
true_pos += nb_objs - diff
false_neg += diff
else:
true_pos = nb_objs
false_pos += abs(diff)

return (true_pos, false_neg, 0, false_pos)

def negative_image_stats(objs_found):
""" Update our general negative image stats.
Args:
objs_found : int
Number of objects found in image.
Returns:
tuple: (true_pos, false_neg, true_neg, false_pos)
"""
true_neg = 0
false_pos = 0
if objs_found == 0:
true_neg = 1
else:
false_pos = objs_found

return (0, 0, true_neg, false_pos)


if __name__ == '__main__':
total_positives = 40
total_negatives = 40
print (positive_image_stats(3, 1))
print (negative_image_stats(0))

0 comments on commit 55f3470

Please sign in to comment.