Beispiel #1
0
def print_dict_latex(stats, top, patient):
    print("\\begin{table}[ht]")
    print("\\resizebox{\\textwidth}{!}{\\begin{tabular}{l|| *{6}{c|}}")
    print(
        "\\hline \\hline",
        "\n\\textbf{Models} & \\textbf{RMSE} & \\textbf{MAPE} & \\textbf{TG} & \\textbf{AP} "
        "& \\textbf{BE} & \\textbf{EP} \\\\ \n\\hline \\hline")
    cpt = 0
    for key in stats.keys():
        mean = [stats[key][key_1][0] for key_1 in stats[key].keys()]
        diff = [stats[key][key_1][1] for key_1 in stats[key].keys()]
        if cpt == 0:
            print_latex(mean, diff, key)
            print("\\hline")
        else:
            print_latex(mean, diff, str(cpt) + "/" + " glucose + " + key)
        cpt += 1
    print("\\hline \\hline")
    print("\\end{tabular}}")
    if patient is None:
        print("\\caption{\\detokenize{Top 5", top, "global models}}")
    else:
        print("\\caption{\\detokenize{Top 5", top, "models for patient",
              str(patient) + "}}")
    print("\\end{table}")
Beispiel #2
0
    def to_latex(self, table="acc", model_name=None):
        """
        Format the results into a string for the paper in LATEX
        :param table: either "acc" or "cg_ega", corresponds to the table
        :param model_name: prefix of the string, name of the model
        :return:
        """
        mean, std = self.compute_results()
        if table == "cg_ega":
            keys = [
                "CG_EGA_AP_hypo", "CG_EGA_BE_hypo", "CG_EGA_EP_hypo",
                "CG_EGA_AP_eu", "CG_EGA_BE_eu", "CG_EGA_EP_eu",
                "CG_EGA_AP_hyper", "CG_EGA_BE_hyper", "CG_EGA_EP_hyper"
            ]
            mean = [mean[k] * 100 for k in keys]
            std = [std[k] * 100 for k in keys]
        elif table == "general":
            acc_keys = ["RMSE", "MAPE", "CG_EGA_AP", "CG_EGA_BE", "CG_EGA_EP"]
            mean = [
                mean[k] if k not in ["CG_EGA_AP", "CG_EGA_BE", "CG_EGA_EP"]
                else mean[k] * 100 for k in acc_keys
            ]
            std = [
                std[k] if k not in ["CG_EGA_AP", "CG_EGA_BE", "CG_EGA_EP"] else
                std[k] * 100 for k in acc_keys
            ]

        print_latex(mean, std, label=self.model)
    def erroneous_prediction_analysis(self, dataset, disp=False):
        """
        Compute the responsability of P-EGA or R-EGA on EP predictions for all the subjects of given dataset
        :param dataset: name of dataset (e.g., "ohio")
        :param disp: if True, print latex format of DataFrame
        :return:
        """
        cg_ega_analysis = []
        for i, sbj, in enumerate(misc.datasets.datasets[dataset]["subjects"]):
            mean_sbj, std_sbj = self.erroneous_prediction_analysis_per_subject(
                dataset, sbj)
            cg_ega_analysis.append(mean_sbj)

            if disp:
                print_latex(mean_sbj, std_sbj, label=sbj)

        cg_ega_analysis = pd.DataFrame(
            data=cg_ega_analysis,
            columns=[
                "Hypo_EP_P", "Hypo_EP_R", "Hypo_EP_B", "Eu_EP_P", "Eu_EP_R",
                "Eu_EP_B", "Hyper_EP_P", "Hyper_EP_R", "Hyper_EP_B"
            ],
            index=misc.datasets.datasets[dataset]["subjects"])
        mean = cg_ega_analysis.mean(axis=0)
        std = cg_ega_analysis.std(axis=0)
        cg_ega_analysis.loc["mean"] = mean
        cg_ega_analysis.loc["std"] = std

        if disp:
            print_latex(mean, std, label=dataset)

        return cg_ega_analysis
Beispiel #4
0
    def to_latex(self, iter=0, table="general", model_name=None):
        """
        Format the results into a string for the paper in LATEX
        :param table: either "acc" or "cg_ega", corresponds to the table
        :param model_name: prefix of the string, name of the model
        :return:
        """
        mean, std = self.compute_results_iter(iter)
        if table == "p_ega":
            p_ega_keys = [
                "P_EGA_A+B", "P_EGA_A", "P_EGA_B", "P_EGA_C", "P_EGA_D",
                "P_EGA_E"
            ]
            mean = [mean[k] * 100 for k in p_ega_keys]
            std = [std[k] * 100 for k in p_ega_keys]

        elif table == "r_ega":
            r_ega_keys = [
                "R_EGA_A+B", "R_EGA_A", "R_EGA_B", "R_EGA_lC", "R_EGA_uC",
                "R_EGA_lD", "R_EGA_uD", "R_EGA_lE", "R_EGA_uC"
            ]
            mean = [mean[k] * 100 for k in r_ega_keys]
            std = [std[k] * 100 for k in r_ega_keys]
        elif table == "cg_ega":
            cg_ega_keys = [
                "CG_EGA_AP_hypo", "CG_EGA_BE_hypo", "CG_EGA_EP_hypo",
                "CG_EGA_AP_eu", "CG_EGA_BE_eu", "CG_EGA_EP_eu",
                "CG_EGA_AP_hyper", "CG_EGA_BE_hyper", "CG_EGA_EP_hyper"
            ]
            mean = [mean[k] * 100 for k in cg_ega_keys]
            std = [std[k] * 100 for k in cg_ega_keys]
        elif table == "acc":
            acc_keys = ["RMSE", "MAPE", "MASE", "TG"]
            mean = [mean[k] for k in acc_keys]
            std = [std[k] for k in acc_keys]
        elif table == "general":
            acc_keys = [
                "RMSE", "MAPE", "MASE", "TG", "CG_EGA_AP", "CG_EGA_BE",
                "CG_EGA_EP"
            ]
            mean = [
                mean[k] if k not in ["CG_EGA_AP", "CG_EGA_BE", "CG_EGA_EP"]
                else mean[k] * 100 for k in acc_keys
            ]
            std = [
                std[k] if k not in ["CG_EGA_AP", "CG_EGA_BE", "CG_EGA_EP"] else
                std[k] * 100 for k in acc_keys
            ]

        print_latex(mean, std, label=self.model)
Beispiel #5
0
def print_dict_stats_physio(stats, variable, patient=None):
    print("\\begin{table}[ht]")
    print("\\resizebox{\\textwidth}{!}{\\begin{tabular}{l|| *{6}{c|}}")
    print(
        "\\hline \\hline",
        "\n\\textbf{Features impact} & \\textbf{RMSE} & \\textbf{MAPE} & \\textbf{TG} & "
        "\\textbf{AP} & \\textbf{BE} & \\textbf{EP} \\\\ \n\\hline")
    for key in stats.keys():
        mean = [stats[key][key_1] for key_1 in stats[key].keys()]
        diff = [stats[key][key_1] for key_1 in stats[key].keys()]
        print_latex(mean, diff, " vs ".join(key))
    print("\\hline \\hline")
    print("\\end{tabular}}")
    if patient is None:
        print("\\caption{" + variable, "impact on all the patients}")
    else:
        print("\\caption{" + variable, "impact for patient",
              str(patient) + "}")
    print("\\end{table}")