Exemplo n.º 1
0
def getReducedDataframe(df, ch, test, configs, cols):
    result = evalgof.compareSideBySide(df, "cc", configs, test, ch)
    result = result.rename(columns={"var": "variable"})
    result.drop(["dc_type", "gof_mode", "test", "channel"],
                axis=1,
                inplace=True)

    return result
Exemplo n.º 2
0
def makeSingleHtml(df, ch, test, configs, cols, name, failing):
    html = ""
            
    result = evalgof.compareSideBySide(df, "cc", configs, test, ch)
    result = result.rename(columns = {"channel":"ch"})
    result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
#     styler = result.style.applymap(color_negative_red) \
#                 .apply(highlight_greater_than_base, subset=cols, axis=1) \
#                 .apply(highlight_smaller_than_base, subset=cols, axis=1) \
#                 .apply(highlight_max, subset=cols, axis=1) \
#                 .apply(highlight_sum, subset=['18'], axis=0)
#                 
#     html = html + styler.render()
    
    if failing:
        f = failing[test][ch]
        print "failing:"
        print f
        
        new_row = {'var':"total failing", 'test':test, 'ch':ch}
        for conf in cols:
            new_row[conf] = str(int(f[conf]))
            
        sum_df = pd.DataFrame([new_row], columns=["var", "test", "ch"] + cols)  
        print sum_df   
        
    result = pd.concat([result, sum_df])
    
    new_index = range(len(result))
    print new_index
    result.index = new_index
#     result.reset_index(inplace=True)
    
    print result
        
    #sum_styler = sum_df.style.hide_index()
    
    #html = html + sum_styler.render()
    
    styler = result.style.applymap(color_negative_red) \
                .apply(highlight_greater_than_base, subset=cols, axis=1) \
                .apply(highlight_smaller_than_base, subset=cols, axis=1) \
                .apply(highlight_max, subset=cols, axis=1) 
#                 .apply(highlight_sum, subset=pd.IndexSlice[18:18, cols])
                
    html = html + styler.render()
    
    
    
    
    file = open('{0}_{1}_{2}.html'.format(ch, test, name), "w+")
    file.write(html)
    file.close()
    
    pdf.from_string(html, '{0}_{1}_{2}.pdf'.format(ch, test, name))
    
    return html
Exemplo n.º 3
0
def makePdf(channel, modes):
    reload(GOFTools.evalgof)
    from IPython.display import display, HTML
    import GOFTools.evalgof as evalgof
    df = evalgof.loadDF("../output/{0}_pvalues.json".format(channel))

    print df

    if not modes:
        base = "cc"
        if "all" in channel:
            configs = [
                "cc1", "cc2", "nn1", "nn2", "nn3", "nn4", "nn5", "nn6", "nn7",
                "nn8", "nn9", "nn10", "nn11", "nn12", "nn13", "nn14", "nn15",
                "nn16", "nn17", "nn18", "nn21"
            ]
            channels = ["et", "mt", "tt"]
        else:
            #         configs = ["cc1", "nn1", "nn2", "nn3", "nn4", "nn5", "nn6", "nn7", "nn8", "nn9", "nn10", "nn11", "nn13", "nn15",
            #                  "nn16", "nn17", "nn18", "nn19", "nn20", "nn15a", "nn16a", "nn17a", "nn18a"]
            #         configs = ["cc1", "nn5", "nn10", "nn13", "nn15", "nn15a", "nn15a2", "nn16", "nn16a", "nn16a2", "nn17", "nn17a", "nn17a2",
            #                    "nn18", "nn18a", "nn18a2", "nn19", "nn20"]
            #         configs = ["cc1", "nn1", "nn2", "nn3", "nn4", "nn5", "nn6", "nn7", "nn8", "nn9", "nn10", "nn11",
            #                "nn13", "nn13a2", "nn14", "nn14a2", "nn15a2", "nn16a2", "nn17a2", "nn18a2"]
            #         configs = ["cc1", "cc2", "nn13", "nn13a2", "nn14", "nn14a2", "nn15", "nn15a", "nn15a2", "nn16", "nn16a", "nn16a2",
            #                    "nn17", "nn17a", "nn17a2", "nn18", "nn18a", "nn18a2",
            #                    "nn1a2", "nn2a2", "nn3a2", "nn4a2", "nn5a2", "nn6a2", "nn7a2", "nn8a2", "nn9a2", "nn10a2", "nn11a2", "nn12a2"]
            #         configs = ["cc1", "cc2", "nn1a2", "nn2a2", "nn3a2", "nn4a2", "nn5a2", "nn6a2", "nn7a2", "nn8a2", "nn9a2", "nn10a2",
            #                    "nn11a2", "nn12a2", "nn13a2", "nn14a2", "nn15a2", "nn16a2", "nn17a2", "nn18a2"]
            #         configs = ["cc1", "cc2", "nn11", "nn11a2", "nn11e", "nn12a2", "nn12e", "nn14a2", "nn14e", "nn16", "nn16a2", "nn16e", "nn18", "nn18a2", "nn18e"]

            #         vanilla
            configs = [
                "cc1", "cc2", "nn1", "nn2", "nn3", "nn4", "nn5", "nn6", "nn7",
                "nn8", "nn9", "nn10", "nn11", "nn12", "nn13", "nn14", "nn15",
                "nn16", "nn17", "nn18", "nn19", "nn20"
            ]

            #         aiso2
            #         configs = ["cc1", "cc2", "nn1a2", "nn2a2", "nn3a2", "nn4a2", "nn5a2", "nn6a2", "nn7a2", "nn8a2", "nn9a2", "nn10a2",
            #                     "nn11a2", "nn12a2","nn13a2", "nn14a2", "nn15a2", "nn16a2", "nn17a2", "nn18a2"]

            #         aiso
            #         configs = ["cc1", "cc2", "nn1a", "nn2a", "nn3a", "nn4a", "nn5a", "nn6a", "nn7a", "nn8a", "nn9a", "nn10a",
            #                     "nn11a", "nn12a","nn13a", "nn14a", "nn15a", "nn16a", "nn17a", "nn18a"]

            #         emb
            #         configs = ["cc1", "cc2", "nn1", "nn2", "nn3", "nn4", "nn5", "nn6", "nn7", "nn8", "nn9", "nn10", "nn11e", "nn12e",
            #                     "nn13", "nn14e", "nn15", "nn16e", "nn17", "nn18e"]

            channels = ["tt"]

        cols = [base] + configs

        for ch in channels:
            html = ""

            result = evalgof.compareSideBySide(df, "cc", configs, "saturated",
                                               ch)
            result = result.rename(columns={"channel": "ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
            styler = result.style.applymap(color_negative_red) \
                        .apply(highlight_greater_than_base, subset=cols, axis=1) \
                        .apply(highlight_smaller_than_base, subset=cols, axis=1) \
                        .apply(highlight_max, subset=cols, axis=1)

            html = html + styler.render()

            result = evalgof.compareSideBySide(df, "cc", configs, "KS", ch)
            result = result.rename(columns={"channel": "ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
            styler = result.style.applymap(color_negative_red) \
                        .apply(highlight_greater_than_base, subset=cols, axis=1) \
                        .apply(highlight_smaller_than_base, subset=cols, axis=1) \
                        .apply(highlight_max, subset=cols, axis=1)

            html = html + "<br/>"
            html = html + styler.render()

            result = evalgof.compareSideBySide(df, "cc", configs, "AD", ch)
            result = result.rename(columns={"channel": "ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
            styler = result.style.applymap(color_negative_red) \
                        .apply(highlight_greater_than_base, subset=cols, axis=1) \
                        .apply(highlight_smaller_than_base, subset=cols, axis=1) \
                        .apply(highlight_max, subset=cols, axis=1)

            html = html + "<br/>"
            html = html + styler.render()

            import pandas as pd
            import pdfkit as pdf
            pdf.from_string(html, '{0}_complete.pdf'.format(ch))

    else:
        base = "cc"
        name = "custom"
        if "all" in channel:
            configs = ["cc1", "cc2"] + modes
            channels = ["et", "mt", "tt"]
        else:
            configs = ["cc1", "cc2"] + modes
            channels = ["tt"]

        cols = [base] + configs

        for ch in channels:
            html = ""

            result = evalgof.compareSideBySide(df, "cc", configs, "saturated",
                                               ch)
            result = result.rename(columns={"channel": "ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
            styler = result.style.applymap(color_negative_red) \
                        .apply(highlight_greater_than_base, subset=cols, axis=1) \
                        .apply(highlight_smaller_than_base, subset=cols, axis=1) \
                        .apply(highlight_max, subset=cols, axis=1)

            html = html + styler.render()

            result = evalgof.compareSideBySide(df, "cc", configs, "KS", ch)
            result = result.rename(columns={"channel": "ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
            styler = result.style.applymap(color_negative_red) \
                        .apply(highlight_greater_than_base, subset=cols, axis=1) \
                        .apply(highlight_smaller_than_base, subset=cols, axis=1) \
                        .apply(highlight_max, subset=cols, axis=1)

            html = html + "<br/>"
            html = html + styler.render()

            result = evalgof.compareSideBySide(df, "cc", configs, "AD", ch)
            result = result.rename(columns={"channel": "ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
            styler = result.style.applymap(color_negative_red) \
                        .apply(highlight_greater_than_base, subset=cols, axis=1) \
                        .apply(highlight_smaller_than_base, subset=cols, axis=1) \
                        .apply(highlight_max, subset=cols, axis=1)

            html = html + "<br/>"
            html = html + styler.render()

            import pandas as pd
            import pdfkit as pdf
            pdf.from_string(html, '{0}_{1}.pdf'.format(ch, name))
Exemplo n.º 4
0
def makeCsv(channel, modes):
    reload(GOFTools.evalgof)
    from IPython.display import display, HTML
    import GOFTools.evalgof as evalgof
    df = evalgof.loadDF("../output/{0}_pvalues.json".format(channel))
    
    print df
    
    if not modes:
        base = "cc"
        if "all" in channel:
            configs = ["cc1", "cc2", "nn1", "nn2", "nn3", "nn4", "nn5", "nn6", "nn7", "nn8", "nn9", "nn10", "nn11", "nn12",
                   "nn13", "nn14", "nn15", "nn16", "nn17", "nn18", "nn21"]
            channels = ["et", "mt", "tt"]
        else:
            
    #         vanilla
            configs = ["cc1", "cc2", "nn1", "nn2", "nn3", "nn4", "nn5", "nn6", "nn7", "nn8", "nn9", "nn10", "nn11", "nn12",
                       "nn13", "nn14", "nn15", "nn16", "nn17", "nn18", "nn19", "nn20"]
            
    #         aiso2
    #         configs = ["cc1", "cc2", "nn1a2", "nn2a2", "nn3a2", "nn4a2", "nn5a2", "nn6a2", "nn7a2", "nn8a2", "nn9a2", "nn10a2", 
    #                     "nn11a2", "nn12a2","nn13a2", "nn14a2", "nn15a2", "nn16a2", "nn17a2", "nn18a2"]
    
    #         aiso
    #         configs = ["cc1", "cc2", "nn1a", "nn2a", "nn3a", "nn4a", "nn5a", "nn6a", "nn7a", "nn8a", "nn9a", "nn10a", 
    #                     "nn11a", "nn12a","nn13a", "nn14a", "nn15a", "nn16a", "nn17a", "nn18a"]
            
    #         emb
    #         configs = ["cc1", "cc2", "nn1", "nn2", "nn3", "nn4", "nn5", "nn6", "nn7", "nn8", "nn9", "nn10", "nn11e", "nn12e",
    #                     "nn13", "nn14e", "nn15", "nn16e", "nn17", "nn18e"]
            
            channels = ["tt"]
        
        cols = [base] + configs
        
        for ch in channels:    
            
            result = evalgof.compareSideBySide(df, "cc", configs, "saturated", ch)
            result = result.rename(columns = {"channel":"ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
                        
            saveCsv(result, "{0}_{1}_complete.csv".format(ch, "saturated"))
            
            result = evalgof.compareSideBySide(df, "cc", configs, "KS", ch)
            result = result.rename(columns = {"channel":"ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
                        
            saveCsv(result, "{0}_{1}_complete.csv".format(ch, "KS"))
            
            result = evalgof.compareSideBySide(df, "cc", configs, "AD", ch)
            result = result.rename(columns = {"channel":"ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
            
            saveCsv(result, "{0}_{1}_complete.csv".format(ch, "AD"))  
            
    else:
        base = "cc"
        name = "custom"
        if "all" in channel:
            configs = ["cc1", "cc2"] + modes
            channels = ["et", "mt", "tt"]
        else:            
            configs = ["cc1", "cc2"] + modes            
            channels = ["tt"]
        
        cols = [base] + configs
        
        for ch in channels:    
            result = evalgof.compareSideBySide(df, "cc", configs, "saturated", ch)
            result = result.rename(columns = {"channel":"ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
                        
            saveCsv(result, "{0}_{1}_{2}.csv".format(ch, "saturated", name))
            
            result = evalgof.compareSideBySide(df, "cc", configs, "KS", ch)
            result = result.rename(columns = {"channel":"ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
                        
            saveCsv(result, "{0}_{1}_{2}.csv".format(ch, "KS", name))
            
            result = evalgof.compareSideBySide(df, "cc", configs, "AD", ch)
            result = result.rename(columns = {"channel":"ch"})
            result.drop(["dc_type", "gof_mode"], axis=1, inplace=True)
            
            saveCsv(result, "{0}_{1}_{2}.csv".format(ch, "AD", name))