示例#1
0


if __name__ == '__main__':
    ut.list_to_csv(head=head)
    result = []
    df_list = []
    name_list = ut_light.gen_list_mix(main_path=dataset_path,data_type='bgs',mix_size="*sq_L3_I5_*")
    for index, name in enumerate(name_list):
        for threshold in thresholds:
            algo_name = "SEA_{}_{}".format(bin_sizes,block_type)
            ut.checkFolderandCreate("{}\\ROC\\{}".format(main_path, algo_name))
            pickle_ROC_file = '{}\\ROC\\{}\\_{}_threshold{}.pkl'.format(main_path, algo_name, name, threshold)
            if not os.path.exists(pickle_ROC_file):
                result = []
                data = ut_light.load_light_select_dataset(input_path=dataset_path, file_name=name, is_mix=is_mix)
                print("##### cal name : {} , threshold = {}  #####".format(name, threshold))
                ROC_row = genROCFile(name=name, data=data, threshold=threshold)
                result.append(ROC_row)
                df = pd.DataFrame(result, columns=ROC_head)
                with open(pickle_ROC_file, 'wb') as output:
                    pickle.dump(df, output)
            else:
                print("##### Load name : {} , threshold = {}  #####".format(name, threshold))
                with open(pickle_ROC_file, 'rb') as pickle_input:
                    df = pickle.load(pickle_input)
            df_list.append(df)
    df = ut.union_DF(df_list=df_list, head_list=ROC_head)
    print("a")
    plt = ut.plot_roc_curve_dy(df=df, name_list=name_list)
    plt.show()
示例#2
0
    directorys = os.listdir(input_path)
    directorys_matching = fnmatch.filter(directorys, pattern)
    return directorys_matching


if __name__ == '__main__':

    name_list = ut_light.gen_list_title(data_type='bgs')
    # name_list = ut_light.gen_list_mix(dataset_path, data_type='bgs',mix_size=mix_size)
    path = "{}\\ROC".format(main_path)
    directorys = get_direct_from_pattern(input_path=path,
                                         input_pattern=pattern)
    for directory in directorys:
        path_directory = "{}\\ROC\\{}".format(main_path, directory)
        pk_list = os.listdir(path_directory)
        df_list = []
        for index, pk_file in enumerate(pk_list):
            pickle_ROC_file = "{}\\{}".format(path_directory, pk_file)
            with open(pickle_ROC_file, 'rb') as pickle_input:
                df = pickle.load(pickle_input)
            df_list.append(df)
        # df_list.append(ut_light.last_df_list(head_list=ROC_head))
        df = ut.union_DF(df_list=df_list, head_list=ROC_head)
        plt = ut.plot_roc_curve_dy(df=df,
                                   name_list=name_list,
                                   algo_name=directory)
        plt.savefig("{}\\pic\\{}_{}.png".format(main_path, directory,
                                                mix_size.replace("*", "")))
        plt.show()
        plt.clf()
        # ut.dftocsv(dataframe_input = df,file_name="csv\\{}.csv".format(directory))