Python seaborn.kdeplot() Examples

The following are 30 code examples of seaborn.kdeplot(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module seaborn , or try the search function .
Example #1
Source File: visualizations.py    From Brancher with MIT License 7 votes vote down vote up
def plot_posterior(model, variables, number_samples=1000):

    # Get samples
    sample = model.get_sample(number_samples)
    post_sample = model.get_posterior_sample(number_samples)

    # Join samples
    sample["Mode"] = "Prior"
    post_sample["Mode"] = "Posterior"
    subsample = sample[variables + ["Mode"]]
    post_subsample = post_sample[variables + ["Mode"]]
    joint_subsample = subsample.append(post_subsample)

    # Plot posterior
    warnings.filterwarnings('ignore')
    g = sns.PairGrid(joint_subsample, hue="Mode")
    g = g.map_offdiag(sns.kdeplot)
    g = g.map_diag(sns.kdeplot, lw=3, shade=True)
    g = g.add_legend()
    warnings.filterwarnings('default') 
Example #2
Source File: mouse_brain_astrocyte.py    From geosketch with MIT License 7 votes vote down vote up
def astro_oligo_joint(X, genes, gene1, gene2, labels, focus, name):
    X = X.toarray()

    gidx1 = list(genes).index(gene1)
    gidx2 = list(genes).index(gene2)

    idx = labels == focus

    x1 = X[(idx, gidx1)]
    x2 = X[(idx, gidx2)]

    plt.figure()
    sns.jointplot(
        x1, x2, kind='scatter', space=0, alpha=0.3
    ).plot_joint(sns.kdeplot, zorder=0, n_levels=10)
    plt.savefig('{}_joint_{}_{}_{}.png'.format(name, focus, gene1, gene2)) 
Example #3
Source File: plot_functions.py    From idea_relations with MIT License 7 votes vote down vote up
def joint_plot(x, y, xlabel=None,
               ylabel=None, xlim=None, ylim=None,
               loc="best", color='#0485d1',
               size=8, markersize=50, kind="kde",
               scatter_color="r"):
    with sns.axes_style("darkgrid"):
        if xlabel and ylabel:
            g = SubsampleJointGrid(xlabel, ylabel,
                    data=DataFrame(data={xlabel: x, ylabel: y}),
                    space=0.1, ratio=2, size=size, xlim=xlim, ylim=ylim)
        else:
            g = SubsampleJointGrid(x, y, size=size,
                    space=0.1, ratio=2, xlim=xlim, ylim=ylim)
        g.plot_joint(sns.kdeplot, shade=True, cmap="Blues")
        g.plot_sub_joint(plt.scatter, 1000, s=20, c=scatter_color, alpha=0.3)
        g.plot_marginals(sns.distplot, kde=False, rug=False)
        g.annotate(ss.pearsonr, fontsize=25, template="{stat} = {val:.2g}\np = {p:.2g}")
        g.ax_joint.set_yticklabels(g.ax_joint.get_yticks())
        g.ax_joint.set_xticklabels(g.ax_joint.get_xticks())
    return g 
Example #4
Source File: mouse_brain_subcluster.py    From geosketch with MIT License 6 votes vote down vote up
def astro_oligo_joint(X, genes, gene1, gene2, labels, focus, name):
    X = X.toarray()

    gidx1 = list(genes).index(gene1)
    gidx2 = list(genes).index(gene2)

    idx = labels == focus

    x1 = X[(idx, gidx1)]
    x2 = X[(idx, gidx2)]

    plt.figure()
    sns.jointplot(
        x1, x2, kind='scatter', space=0, alpha=0.3
    ).plot_joint(sns.kdeplot, zorder=0, n_levels=10)
    plt.savefig('{}_joint_{}_{}_{}.png'.format(name, focus, gene1, gene2)) 
Example #5
Source File: artificial_example.py    From mann with GNU General Public License v3.0 6 votes vote down vote up
def plot_activations(a_s,a_t,save_name):
    """
    activation visualization via seaborn library
    """
    n_dim=a_s.shape[1]
    n_rows=1
    n_cols=int(n_dim/n_rows)
    fig, axs = plt.subplots(nrows=n_rows,ncols=n_cols, sharey=True,
                            sharex=True)
    for k,ax in enumerate(axs.reshape(-1)):
        if k>=n_dim:
            continue
        sns.kdeplot(a_t[:,k],ax=ax, shade=True, label='target',
                    legend=False, color='0.4',bw=0.03)
        sns.kdeplot(a_s[:,k],ax=ax, shade=True, label='source',
                    legend=False, color='0',bw=0.03)
        plt.setp(ax.xaxis.get_ticklabels(),fontsize=10)
        plt.setp(ax.yaxis.get_ticklabels(),fontsize=10)
    fig.set_figheight(3)
    plt.setp(axs, xticks=[0, 0.5, 1])
    plt.setp(axs, ylim=[0,10])
    plt.savefig(save_name)


# load dataset 
Example #6
Source File: plotting.py    From fitbit-analyzer with Apache License 2.0 6 votes vote down vote up
def plotCorrelation(stats):
    #columnsToDrop = ['sleep_interval_max_len', 'sleep_interval_min_len',
    #                 'sleep_interval_avg_len', 'sleep_inefficiency',
    #                 'sleep_hours', 'total_hours']

    #stats = stats.drop(columnsToDrop, axis=1)

    g = sns.PairGrid(stats)
    def corrfunc(x, y, **kws):
        r, p = scipystats.pearsonr(x, y)
        ax = plt.gca()
        ax.annotate("r = {:.2f}".format(r),xy=(.1, .9), xycoords=ax.transAxes)
        ax.annotate("p = {:.2f}".format(p),xy=(.2, .8), xycoords=ax.transAxes)
        if p>0.04:
            ax.patch.set_alpha(0.1)

    g.map_upper(plt.scatter)
    g.map_diag(plt.hist)
    g.map_lower(sns.kdeplot, cmap="Blues_d")
    g.map_upper(corrfunc)
    sns.plt.show() 
Example #7
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #8
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #9
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #10
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #11
Source File: visualize.py    From adversarial-policies with MIT License 5 votes vote down vote up
def comparative_densities(
    env, victim_id, n_components, covariance, cutoff_point=None, savefile=None, **kwargs
):
    """PDF of different opponents density distribution.
    For unspecified parameters, see get_full_directory.

    :param cutoff_point: (float): left x-limit.
    :param savefile: (None or str) path to save figure to.
    :param kwargs: (dict) passed through to sns.kdeplot."""
    df = load_metadata(env, victim_id, n_components, covariance)
    fig = plt.figure(figsize=(10, 7))

    grped = df.groupby("opponent_id")
    for name, grp in grped:
        # clean up random_none to just random
        name = name.replace("_none", "")
        avg_log_proba = np.mean(grp["log_proba"])
        sns.kdeplot(grp["log_proba"], label=f"{name}: {round(avg_log_proba, 2)}", **kwargs)

    xmin, xmax = plt.xlim()
    xmin = max(xmin, cutoff_point)
    plt.xlim((xmin, xmax))

    plt.suptitle(f"{env} Densities, Victim Zoo {victim_id}: Trained on Zoo 1", y=0.95)
    plt.title("Avg Log Proba* in Legend")

    if savefile is not None:
        fig.savefig(f"{savefile}.pdf") 
Example #12
Source File: example_viz_parametric_tSNE.py    From parametric_tsne with MIT License 5 votes vote down vote up
def _plot_kde(output_res, pick_rows, color_palette, alpha=0.5):
    num_clusters = len(set(pick_rows))
    for ci in range(num_clusters):
        cur_plot_rows = pick_rows == ci
        cur_cmap = sns.light_palette(color_palette[ci], as_cmap=True)
        sns.kdeplot(output_res[cur_plot_rows, 0], output_res[cur_plot_rows, 1], cmap=cur_cmap, shade=True, alpha=alpha,
            shade_lowest=False)
        centroid = output_res[cur_plot_rows, :].mean(axis=0)
        plt.annotate('%s' % ci, xy=centroid, xycoords='data', alpha=0.5,
                     horizontalalignment='center', verticalalignment='center') 
Example #13
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #14
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #15
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #16
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #17
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #18
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #19
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #20
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #21
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #22
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #23
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #24
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #25
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #26
Source File: model_visualizer.py    From U-Net-Fixed-Point-Quantization-for-Medical-Image-Segmentation with MIT License 5 votes vote down vote up
def plot_tensor(tensor, ax, name, config):
    tensor = torch.abs(tensor)
    #import ipdb as pdb; pdb.set_trace()
    #print(tensor.shape)
    ax.set_title(name, fontsize="small")
    ax.xaxis.set_tick_params(labelsize=6)
    ax.yaxis.set_tick_params(labelsize=6)
    if config["quantization"].lower() == "fixed":
        #ax.hist(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), normed=True)
        sns.distplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax, kde_kws={"color": "r"})
        #sns.kdeplot(quant.to_fixed_point(tensor, config["weight_i_width"], config["weight_f_width"]).detach().numpy(), ax=ax,  shade=True)
    elif config["quantization"].lower() == "normal":
        sns.distplot(tensor.detach().numpy(), ax=ax, kde_kws={"color": "r"}) 
Example #27
Source File: verification.py    From msprime with GNU General Public License v3.0 5 votes vote down vote up
def plot_breakpoints_hist(v1, v2, v1_name, v2_name):
    sns.kdeplot(v1, color="b", label=v1_name, shade=True, legend=False)
    sns.kdeplot(v2, color="r", label=v2_name, shade=True, legend=False)
    pyplot.legend(loc="upper right") 
Example #28
Source File: visualizations.py    From Brancher with MIT License 5 votes vote down vote up
def _joint_grid(col_x, col_y, col_k, df, k_is_color=False, scatter_alpha=.85):

    def colored_kde(x, y, c=None):
        def kde(*args, **kwargs):
             args = (x, y)
             if c is not None:
                 kwargs['c'] = c
             kwargs['alpha'] = scatter_alpha
             sns.kdeplot(*args, **kwargs)
        return kde

    g = sns.JointGrid(
        x=col_x,
        y=col_y,
        data=df
    )
    color = None
    legends = []
    for name, df_group in df.groupby(col_k):
        legends.append(name)
        if k_is_color:
            color=name
        g.plot_joint(
            colored_kde(df_group[col_x], df_group[col_y], color),
        )
        sns.kdeplot(
            df_group[col_x].values,
            ax=g.ax_marg_x,
            color=color,
            shade=True
        )
        sns.kdeplot(
            df_group[col_y].values,
            ax=g.ax_marg_y,
            color=color,
            shade=True,
            vertical=True
        )
    plt.legend(legends) 
Example #29
Source File: visualizations.py    From Brancher with MIT License 5 votes vote down vote up
def plot_density(model, variables, number_samples=2000):
    sample = model.get_sample(number_samples)
    warnings.filterwarnings('ignore')
    g = sns.PairGrid(sample[variables])
    g = g.map_offdiag(sns.kdeplot)
    g = g.map_diag(sns.kdeplot, lw=3, shade=True)
    g = g.add_legend()
    warnings.filterwarnings('default') 
Example #30
Source File: ave_splitter.py    From AMPL with MIT License 5 votes vote down vote up
def plot_nn_dist_distr(params):
    """
    Plot distributions of nearest neighbor distances
    """
    import matplotlib.pyplot as plt
    import seaborn as sns

    split_set, aa_dist, ii_dist, ai_dist, ia_dist, thresholds = params[:]
    vaI, viI, taI, tiI = split_set
    
    # get the slices of the distance matrices
    aTest_aTrain_D = aa_dist[ np.ix_( vaI, taI ) ]
    aTest_iTrain_D = ai_dist[ np.ix_( vaI, tiI ) ]
    iTest_aTrain_D = ia_dist[ np.ix_( viI, taI ) ] 
    iTest_iTrain_D = ii_dist[ np.ix_( viI, tiI ) ]

    aa_nn_dist = np.min(aTest_aTrain_D, axis=1)
    ai_nn_dist = np.min(aTest_iTrain_D, axis=1)
    ia_nn_dist = np.min(iTest_aTrain_D, axis=1)
    ii_nn_dist = np.min(iTest_iTrain_D, axis=1)

    # Plot distributions of nearest-neighbor distances
    fig, axes = plt.subplots(2, 2, figsize=(12,12))
    sns.kdeplot(aa_nn_dist, ax=axes[0,0])
    axes[0,0].set_title('AA')
    sns.kdeplot(ai_nn_dist, ax=axes[0,1])
    axes[0,1].set_title('AI')
    sns.kdeplot(ia_nn_dist, ax=axes[1,0])
    axes[1,0].set_title('II')
    sns.kdeplot(ii_nn_dist, ax=axes[1,1])
    axes[1,1].set_title('IA')

#*******************************************************************************************************************************************