def build_report(counts):
overall, by_type = metrics(counts)
x = PrettyTable()
x.field_names = ["Category", "P", "R", "F1"]
x.add_row(["OVERALL", "{:02.2f}".format((100. * overall.prec)), "{:02.2f}".format((100. * overall.rec)),
"{:02.2f}".format((100. * overall.fscore))])
for i, m in sorted(by_type.items()):
x.add_row([i, "{:02.2f}".format((100. * m.prec)), "{:02.2f}".format((100. * m.rec)),
"{:02.2f}".format((100. * m.fscore))])
x.align["Category"] = "r"
return x
评论列表
文章目录