def calculate_stats(stats):
"""Calculate derived stats and put them into the given results_pb2.Stats."""
stats.error_message = ''
if stats.true_positives + stats.false_positives:
stats.precision = (float(stats.true_positives) /
(stats.true_positives + stats.false_positives))
else:
stats.precision = float('NaN')
stats.error_message += 'Precision has denominator of zero. '
if stats.true_positives + stats.false_negatives:
stats.recall = (float(stats.true_positives) /
(stats.true_positives + stats.false_negatives))
else:
stats.recall = float('NaN')
stats.error_message += 'Recall has denominator of zero. '
stats.f_score = hmean(stats.precision, stats.recall)
if math.isnan(stats.f_score):
stats.error_message += 'f-score is NaN'
return stats
run_pipeline_lib.py 文件源码
python
阅读 36
收藏 0
点赞 0
评论 0
评论列表
文章目录