# -- Calculate the average min (for each label pair separately) score for every problem
if False:
    avg_min_u_score = np.ones(problem_paths.shape[0]) * np.NaN
    ustat_paths = np.array(glob.glob(intermediate_data_root + "/*_ustat.npy"))
    reg_ex = re.compile("../data/(.*)_ustat.npy")
    ustat_names = np.array([reg_ex.match(ustat_path).group(1) for ustat_path in ustat_paths])
    # -- sort ustat paths to match the problem_paths
    ustat_sort_ind = hlp.ismember(problem_names, ustat_names)
    ustat_paths = ustat_paths[ustat_sort_ind]
    ustat_names = ustat_names[ustat_sort_ind]

    for i, (ustat_path, mat_file_path) in enumerate(zip(ustat_paths, problem_paths)):
        ustat = np.load(ustat_path)
        # -- calculate the scaling factor for every label pairing of the current classification problem
        u_scale = testst.u_stat_norm_factor(mat_file_path, is_from_old_matlab="True")
        print ustat_path
        avg_min_u_score[i] = (np.min(ustat, axis=1) / u_scale).mean()
    np.save(avg_min_u_score_path, avg_min_u_score)
else:
    avg_min_u_score = np.load(avg_min_u_score_path)
# -- average minimum (for each class pair) U-score for top features
ax_measures10.plot(x_loc, avg_min_u_score[porblem_sort_ind], marker="o", label="avg. min. U-score all")
ax_measures10.legend(loc=2, fontsize="small", labelspacing=0.1)
ax_measures10.set_ylabel("u-score")

# ax_measures1.plot(x_loc,(~all_classes_avg_masked_sort.mask).sum(axis=1))
# plt.savefig('/home/philip/Desktop/tmp/figure_tmp/u_stat_array.png')
# plt.savefig('/home/philip/Desktop/tmp/figure_tmp/u_stat_array_z_column.png')

plt.show()
Beispiel #2
0
if False:
    avg_min_u_score = np.ones(problem_paths.shape[0]) * np.NaN
    ustat_paths = np.array(glob.glob(intermediate_data_root + '/*_ustat.npy'))
    reg_ex = re.compile('../data/(.*)_ustat.npy')
    ustat_names = np.array(
        [reg_ex.match(ustat_path).group(1) for ustat_path in ustat_paths])
    # -- sort ustat paths to match the problem_paths
    ustat_sort_ind = hlp.ismember(problem_names, ustat_names)
    ustat_paths = ustat_paths[ustat_sort_ind]
    ustat_names = ustat_names[ustat_sort_ind]

    for i, (ustat_path,
            mat_file_path) in enumerate(zip(ustat_paths, problem_paths)):
        ustat = np.load(ustat_path)
        # -- calculate the scaling factor for every label pairing of the current classification problem
        u_scale = testst.u_stat_norm_factor(mat_file_path,
                                            is_from_old_matlab='True')
        print ustat_path
        avg_min_u_score[i] = (np.min(ustat, axis=1) / u_scale).mean()
    np.save(avg_min_u_score_path, avg_min_u_score)
else:
    avg_min_u_score = np.load(avg_min_u_score_path)
# -- average minimum (for each class pair) U-score for top features
ax_measures10.plot(x_loc,
                   avg_min_u_score[porblem_sort_ind],
                   marker='o',
                   label='avg. min. U-score all')
ax_measures10.legend(loc=2, fontsize='small', labelspacing=.1)
ax_measures10.set_ylabel('u-score')

# ax_measures1.plot(x_loc,(~all_classes_avg_masked_sort.mask).sum(axis=1))
#plt.savefig('/home/philip/Desktop/tmp/figure_tmp/u_stat_array.png')