in prediction_generation/make_table.py [0:0]
def write_latex(results, dim=None, is_avg=None):
if is_avg:
raise NotImplementedError(
"write_latex is not supported for is_avg = True"
)
methods = sorted(set(r.method.name for r in results))
datasets = sorted(set(r.dataset for r in results))
if dim == "combined":
uni_datasets = DATASETS
datasets = sorted(uni_datasets)
textsc = lambda m: "\\textsc{%s}" % m
verb = lambda m: "\\verb+%s+" % m
headers = ["Dataset"] + list(map(textsc, methods))
table = []
for dataset in datasets:
row = [verb(dataset)]
for method in methods:
m = Method(method)
r = next((r for r in results if r.method == m and r.dataset == dataset))
row.append(r.placeholder if r.score is None else r.score)
table.append(row)
spec = "l" + "c" * len(methods)
tex = build_latex_table(table, headers, floatfmt=".3f", table_spec=spec)
if dim == "combined":
# add a horizontal line for these datasets
lines = tex.split("\n")
newlines = []
for line in lines:
newlines.append(line)
tex = "\n".join(newlines)
print(tex)