예제 #1
0
sys.path.append('../../teca')

from analytics.metrix import bcubed_pr_scores

clusters_y = np.array([
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
    # 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
    # 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
    # 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
])
categories_y = np.array([
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    # 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
    # 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
    # 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
])

clusters_y = [1]*500 + [2]*500 + [3]*500 + [4]*200 + [5]*200 + [6]*200 + [7]*200
clusters_y = np.array(clusters_y)
categories_y = np.random.permutation(clusters_y)
categories_y = np.array(categories_y)
# categories_y = clusters_y

print categories_y

print bcubed_pr_scores(clusters_y, categories_y)
예제 #2
0
# fg2 = plt.figure(num=2, figsize=(30, 8), dpi=80, facecolor='w', edgecolor='k')
# ax2 = fg2.add_subplot(111)

# i = 0
# bar_width = 0.15

for params_lst, params_path in zip(
    param_comb.ParamGridIter(params_range, "list"), param_comb.ParamGridIter(params_range, "path")
):

    clstr_y, clss_y, clstr_params = get_predictions(h5df, params_path, class_tag=None)

    clstr_y = clstr_y.reshape(1, clstr_y.shape[0])

    pre_bc, rec_bc, size_per_clstr, size_per_cats = bcubed_pr_scores(clstr_y[0], clss_y[0])

    print str(clstr_y.shape[1]) + ", " + ", ".join([str(i) for i in size_per_clstr[1::]]) + ", " + ", ".join(
        [str(i) for i in size_per_cats[1::]]
    ) + ", " + ", ".join([str(i) for i in clstr_params]) + ", " + str(params_lst[1]) + ", " + str(pre_bc) + ", " + str(
        rec_bc
    )

    # ", ".join([str(i) for i in params_lst])

    # plt.locator_params(nbins=4)
    # ax1.plot(
    #     x, y,
    #     color[i] + line_type[i] + symbol[i], linewidth=1,
    #     markeredgewidth=1,
    #     # label="KI04 - 3Words"