def plot(out,labels,name):
    # plot
    img_size = 15
    fig, ax = plt.subplots()
    im, cbar = ahm.heatmap(out, labels, labels, ax=ax,
                       cmap="gist_heat", cbarlabel='Jaccard Index')
    ahm.annotate_heatmap(im, valfmt="{x:.1f}", fontsize = 10)
    fig.tight_layout()
    fig = plt.gcf()
    fig.set_size_inches(img_size, img_size)
#    plt.show()
    fig.savefig('heatmaps/'+name+'.png', dpi=100, transparent = True)
def plot(out, labels, name):
    # plot
    img_size = 15
    fig, ax = plt.subplots()
    im, cbar = ahm.heatmap(out,
                           labels,
                           labels,
                           ax=ax,
                           cmap="gist_heat",
                           cbarlabel='Jaccard Index')
    ahm.annotate_heatmap(im, valfmt="{x:.1f}", fontsize=10)
    fig.tight_layout()
    fig = plt.gcf()
    fig.set_size_inches(img_size, img_size)
    plt.show()
Ejemplo n.º 3
0
def output_csv_heatmap(corpus_load_path,
                       ngram,
                       second_order,
                       ignore_frequency,
                       csv_save_path,
                       heatmap_save_path,
                       inds,
                       img_size=10,
                       font_size=20,
                       annotate=False):
    # load test corpus
    wd, mydict = loadCorpus(corpus_load_path)

    # get first order matrix
    f = jac.get_jaccard_matrix(wd, ngram, second_order, ignore_frequency)
    np.fill_diagonal(f, 0)

    out = pd.DataFrame(f)
    out.columns = list(mydict.keys())
    out.index = list(mydict.keys())
    out.to_csv(csv_save_path, index=False)

    # plot first order
    fig, ax = plt.subplots()

    im, cbar = ahm.heatmap(f[:inds, :inds],
                           list(mydict.keys())[:inds],
                           list(mydict.keys())[:inds],
                           ax=ax,
                           cmap="gist_heat",
                           cbarlabel='Jaccard Index')
    if annotate:
        ahm.annotate_heatmap(im, valfmt="{x:.2f}", fontsize=font_size)

    fig.tight_layout()

    fig = plt.gcf()
    fig.set_size_inches(img_size, img_size)
    #plt.show()
    fig.savefig(heatmap_save_path, dpi=100, transparent=True)
Ejemplo n.º 4
0
    vect = np.ones(dims, 'complex128')
    for i in sparse.find(row)[1]:
        vect *= np.fft.fft(vects[i])
    for i in sparse.find(row)[1]:
        mem_conv[i] += vect

mem_conv = np.fft.irfft(mem_conv)

first_conv = cosine_table_self(mem_conv)
np.fill_diagonal(first_conv, 0)

img_size = 15
fig, ax = plt.subplots()
im, cbar = ahm.heatmap(first_conv,
                       sorted(mydict.keys()),
                       sorted(mydict.keys()),
                       ax=ax,
                       cmap="gist_heat",
                       cbarlabel='Jaccard Index')
ahm.annotate_heatmap(im, valfmt="{x:.1f}", fontsize=10)
fig.tight_layout()
fig = plt.gcf()
fig.set_size_inches(img_size, img_size)

second_conv = cosine_table_self(first_conv)
np.fill_diagonal(second_conv, 0)

img_size = 15
fig, ax = plt.subplots()
im, cbar = ahm.heatmap(second_conv,
                       sorted(mydict.keys()),
                       sorted(mydict.keys()),