Exemplo n.º 1
0
def test_centrality(centrality_f, reverse=False):
    node_good = (pnode_good, version_good)
    node_bad = (pnode_bad, version_bad)

    dg_good, nodes_good = graph.make_graph(good)
    name = histogram.get_name(dg_good, node_good)

    if reverse:
        rank_good = centrality_f(dg_good.reverse(copy=True))
    else:
        rank_good = centrality_f(dg_good)
    counts_good = histogram.aggregate(dg_good, rank_good)
    kdes_good = histogram.counts_to_kdes(counts_good)

    # REMOVE
    print counts_good[name]
    print "mean", np.mean(counts_good[name])

    print
    print
    print ">>>>>GOOD ON GOOD"
    r_good = rank_good[node_good]
    pre_good = histogram.kde_predict(kdes_good[name], rank_good[node_good])
    print node_good, name, r_good, pre_good


    dg_bad, nodes_bad = graph.make_graph(bad)
    name = histogram.get_name(dg_bad, node_bad)

    if histogram.SHOULD_HARDCODE_GCC:
        name = "/usr/bin/gcc"

    print ">>>>>BAD ON GOOD"
    if reverse:
        rank_bad = centrality_f(dg_bad.reverse(copy=True))
    else:
        rank_bad = centrality_f(dg_bad)

    r_bad = rank_bad[node_bad]
    pre_bad = histogram.kde_predict(kdes_good[name], rank_bad[node_bad])
    print node_bad, name, r_bad, pre_bad

    print ">>>>>COMPARISON"
    print "diff (good - bad)", name, "rank diff", r_good - r_bad, "prediction diff", pre_good - pre_bad
Exemplo n.º 2
0
def test_centrality(centrality_f, reverse=False):
    node_good = (pnode_good, version_good)
    node_bad = (pnode_bad, version_bad)

    dg_good, nodes_good = graph.make_graph(good)
    name = histogram.get_name(dg_good, node_good)

    if reverse:
        rank_good = centrality_f(dg_good.reverse(copy=True))
    else:
        rank_good = centrality_f(dg_good)
    counts_good = histogram.aggregate(dg_good, rank_good)
    kdes_good = histogram.counts_to_kdes(counts_good)

    # REMOVE
    print counts_good[name]
    print "mean", np.mean(counts_good[name])

    print
    print
    print ">>>>>GOOD ON GOOD"
    r_good = rank_good[node_good]
    pre_good = histogram.kde_predict(kdes_good[name], rank_good[node_good])
    print node_good, name, r_good, pre_good

    dg_bad, nodes_bad = graph.make_graph(bad)
    name = histogram.get_name(dg_bad, node_bad)

    if histogram.SHOULD_HARDCODE_GCC:
        name = "/usr/bin/gcc"

    print ">>>>>BAD ON GOOD"
    if reverse:
        rank_bad = centrality_f(dg_bad.reverse(copy=True))
    else:
        rank_bad = centrality_f(dg_bad)

    r_bad = rank_bad[node_bad]
    pre_bad = histogram.kde_predict(kdes_good[name], rank_bad[node_bad])
    print node_bad, name, r_bad, pre_bad

    print ">>>>>COMPARISON"
    print "diff (good - bad)", name, "rank diff", r_good - r_bad, "prediction diff", pre_good - pre_bad
Exemplo n.º 3
0
        maxx = 1
        numbins = 3
    else:
        numbins = 10
    x = np.linspace(minx, maxx, 100)
    axis.hist(l, bins=numbins, color='g')
    axis.tick_params(axis='y', colors='g')
    axis.set_xlim((minx, maxx))
    axis.set_title(name)

    # plot kde
    ax2 = axis.twinx()
    axarr2[row, col] = ax2

    kde = h.kde_make(l)
    y = [h.kde_predict(kde, xp) for xp in x]
    ax2.plot(x, y, color='b')
    col = (col + 1) % dim
    if col == 0:
        row += 1

# And finally we get to plot things...
colors = ('Green', 'Red', 'Blue')
#for ax, color in zip(axes, colors):
#    data = np.random.random(1) * np.random.random(10)
#    ax.plot(data, marker='o', linestyle='none', color=color)
#    ax.set_ylabel('%s Thing' % color, color=color)
#    ax.tick_params(axis='y', colors=color)
#ax.axvline(x=7.4145, color='r')

fig.tight_layout()
Exemplo n.º 4
0
        maxx = 1
        numbins = 3
    else:
        numbins = 10
    x = np.linspace(minx, maxx, 100)
    axis.hist(l, bins=numbins, color="g")
    axis.tick_params(axis="y", colors="g")
    axis.set_xlim((minx, maxx))
    axis.set_title(name)

    # plot kde
    ax2 = axis.twinx()
    axarr2[row, col] = ax2

    kde = h.kde_make(l)
    y = [h.kde_predict(kde, xp) for xp in x]
    ax2.plot(x, y, color="b")
    col = (col + 1) % dim
    if col == 0:
        row += 1

# And finally we get to plot things...
colors = ("Green", "Red", "Blue")
# for ax, color in zip(axes, colors):
#    data = np.random.random(1) * np.random.random(10)
#    ax.plot(data, marker='o', linestyle='none', color=color)
#    ax.set_ylabel('%s Thing' % color, color=color)
#    ax.tick_params(axis='y', colors=color)
# ax.axvline(x=7.4145, color='r')

fig.tight_layout()