def make_table()

in prediction_generation/original-project/analysis/scripts/aggregate_table_wide.py [0:0]


def make_table(uni_default_cover, uni_default_f1, uni_best_cover, uni_best_f1, methods):
    """Create part of the aggregate table
    """
    tex = []
    tex.append("%% This table requires booktabs!")

    tex.append("\\begin{tabular}{lrr|rrrr|rr}")
    superheader = (
        " & ".join(
            [
                "",
                "\\multicolumn{4}{c}{Univariate}",
                "\\multicolumn{4}{c}{Multivariate} \\\\",
            ]
        )
        + "\\cmidrule(lr){2-5}\\cmidrule(lr){6-9}"
    )
    tex.append(superheader)
    header = (
        " & ".join(
            [
                "",
                "\\multicolumn{2}{c}{Default}",
                "\\multicolumn{2}{c}{Best}",
                "\\multicolumn{2}{c}{Default}",
                "\\multicolumn{2}{c}{Best} \\\\",
            ]
        )
        + "\\cmidrule(lr){2-3}"
        + "\\cmidrule(lr){4-5}"
        + "\\cmidrule(lr){6-7}"
        + "\\cmidrule(lr){8-9}"
    )
    tex.append(header)
    subheader = (
        " & ".join(
            [
                "",
                "Cover",
                "F1",
                "Cover",
                "F1",
                "Cover",
                "F1",
                "Cover",
                "F1" + "\\\\",
            ]
        )
        + "\\cmidrule(r){1-1}"
        + "\\cmidrule(lr){2-5}"
        + "\\cmidrule(l){6-9}"
    )
    tex.append(subheader)

    table = []

    L = max(map(len, methods))
    textsc = lambda m: "\\textsc{%s}%s" % (m, (L - len(m)) * " ")
    table.append(list(map(textsc, methods)))

    all_exps = [uni_default_cover, uni_default_f1, uni_best_cover, uni_best_f1]

    for exp in all_exps:
        row = []
        maxscore = max((exp[m] for m in methods if m in exp))
        for m in methods:
            if m not in exp:
                row.append(5 * " ")
                continue
            score = exp[m]
            scorestr = tabulate._format(
                score, tabulate._float_type, ".3f", ""
            )
            if score == maxscore:
                row.append("\\textbf{%s}" % scorestr)
            else:
                row.append(scorestr)
        table.append(row)

    transposed = list(zip(*table))
    for row in transposed:
        tex.append(" & ".join(row) + " \\\\")
    tex.append("\\cmidrule(r){1-1}\\cmidrule(lr){2-5}\\cmidrule(l){6-9}")
    tex.append("\\end{tabular}")

    return tex