python类set_style()的实例源码

nanoQC.py 文件源码 项目:nanoQC 作者: wdecoster 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def plot_nucleotide_diversity(ax, fqlists, invert=False):
    '''
    Create a FastQC-like "?Per base sequence content" plot
    Plot fraction of nucleotides per position
    zip will stop when shortest read is exhausted
    '''
    if invert:
        fqlists = [list(reversed(read)) for read in fqlists]
    numreads = len(fqlists)
    sns.set_style("darkgrid")
    l_A, = ax.plot(
        np.array([pos.count('A') / numreads for pos in zip(*fqlists)]), 'green', label='A')
    l_T, = ax.plot(
        np.array([pos.count('T') / numreads for pos in zip(*fqlists)]), 'red', label='T')
    l_G, = ax.plot(
        np.array([pos.count('G') / numreads for pos in zip(*fqlists)]), 'black', label='G')
    l_C, = ax.plot(
        np.array([pos.count('C') / numreads for pos in zip(*fqlists)]), 'blue', label='C')
    if invert:
        ax.set_xticklabels(-1 * ax.get_xticks().astype(int))
    return [l_A, l_T, l_G, l_C]
nanoQC.py 文件源码 项目:nanoQC 作者: wdecoster 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def plot_qual(ax, quallist, invert=False):
    '''
    Create a FastQC-like "?Per base sequence quality?" plot
    Plot average quality per position
    zip will stop when shortest read is exhausted
    '''
    sns.set_style("darkgrid")
    if invert:
        l_Q, = ax.plot(np.array([np.mean(position) for position in zip(
            *[list(reversed(read)) for read in quallist])]), 'orange', label="Quality")
        ax.set_xlabel('Position in read from end')
        ax.set_xticklabels(-1 * ax.get_xticks().astype(int))
    else:
        l_Q, = ax.plot(np.array([np.mean(position)
                                 for position in zip(*quallist)]), 'orange', label="Quality")
        ax.set_xlabel('Position in read from start')
    return l_Q
callbacks.py 文件源码 项目:keras-utilities 作者: cbaziotis 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def on_train_begin(self, logs={}):
        sns.set_style("whitegrid")
        sns.set_style("whitegrid", {"grid.linewidth": 0.5,
                                    "lines.linewidth": 0.5,
                                    "axes.linewidth": 0.5})
        flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e",
                  "#2ecc71"]
        sns.set_palette(sns.color_palette(flatui))
        # flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
        # sns.set_palette(sns.color_palette("Set2", 10))

        plt.ion()  # set plot to animated
        self.fig = plt.figure(
            figsize=(self.width * (1 + len(self.get_metrics(logs))),
                     self.height))  # width, height in inches

        # move it to the upper left corner
        move_figure(self.fig, 25, 25)
callbacks.py 文件源码 项目:keras-utilities 作者: cbaziotis 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def on_train_begin(self, logs={}):
        for layer in self.get_trainable_layers():
            for param in self.parameters:
                if any(w for w in layer.weights if param in w.name.split("_")):
                    name = layer.name + "_" + param
                    self.layers_stats[name]["values"] = numpy.asarray(
                        []).ravel()
                    for s in self.stats:
                        self.layers_stats[name][s] = []

        # plt.style.use('ggplot')
        plt.ion()  # set plot to animated
        width = 3 * (1 + len(self.stats))
        height = 2 * len(self.layers_stats)
        self.fig = plt.figure(
            figsize=(width, height))  # width, height in inches
        # sns.set_style("whitegrid")
        # self.draw_plot()
question_dialogues.py 文件源码 项目:guesswhat 作者: GuessWhatGame 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, path, games, logger, suffix):
        super(QuestionVsDialogue, self).__init__(path, self.__class__.__name__, suffix)

        q_by_d = []
        for game in games:
            q_by_d.append(len(game.questions))

        sns.set_style("whitegrid", {"axes.grid": False})


        #ratio question/dialogues
        f = sns.distplot(q_by_d, norm_hist =True, kde=False, bins=np.arange(0.5, 25.5, 1))
        f.set_xlim(0.5,25.5)
        f.set_ylim(bottom=0)

        f.set_xlabel("Number of questions", {'size':'14'})
        f.set_ylabel("Ratio of dialogues", {'size':'14'})
word_question.py 文件源码 项目:guesswhat 作者: GuessWhatGame 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, path, games, logger, suffix):
        super(WordVsQuestion, self).__init__(path, self.__class__.__name__, suffix)


        w_by_q = []
        for game in games:
            for q in game.questions:
                q = re.sub('[?]', '', q)
                words = re.findall(r'\w+', q)
                w_by_q.append(len(words))

        sns.set_style("whitegrid", {"axes.grid": False})

        # ratio question/words
        f = sns.distplot(w_by_q, norm_hist=True, kde=False, bins=np.arange(2.5, 15.5, 1), color="g")

        f.set_xlabel("Number of words", {'size': '14'})
        f.set_ylabel("Ratio of questions", {'size': '14'})
        f.set_xlim(2.5, 14.5)
        f.set_ylim(bottom=0)
dab_deconv_area.py 文件源码 项目:DAB_analyzer 作者: meklon 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def plot_group(data_frame, path_output):
    # optional import
    import seaborn as sns
    path_output_image = os.path.join(path_output, "summary_statistics.png")

    # # Plotting swarmplot
    # plt.figure(num=None, figsize=(15, 7), dpi=120)
    # sns.set_style("whitegrid")
    #
    # plt.title('Violin plot with single measurements')
    # sns.violinplot(x="Group", y="DAB+ area", data=data_frame, inner=None)
    # sns.swarmplot(x="Group", y="DAB+ area", data=data_frame, color="w", alpha=.5)
    # plt.savefig(path_output_image)
    #
    # plt.tight_layout()

    sns.set_style("whitegrid")
    sns.set_context("talk")
    plt.figure(num=None, figsize=(15, 7), dpi=120)
    plt.ylim(0, 100)
    plt.title('Box plot')
    sns.boxplot(x="Group", y="DAB+ area, %", data=data_frame)

    plt.tight_layout()
    plt.savefig(path_output_image, dpi=300)
performance.py 文件源码 项目:spotlight 作者: maciejkula 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def plot(dims, sequence, factorization):

    import matplotlib
    matplotlib.use('Agg')  # NOQA
    import matplotlib.pyplot as plt
    import seaborn as sns

    sns.set_style("darkgrid")

    plt.ylabel("Speed improvement")
    plt.xlabel("Size of embedding layers")
    plt.title("Fitting speed (1.0 = no change)")
    plt.xscale('log')

    plt.plot(dims,
             1.0 / sequence,
             label='Sequence model')
    plt.plot(dims,
             1.0 / factorization,
             label='Factorization model')
    plt.legend(loc='lower right')
    plt.savefig('speed.png')
    plt.close()
plot-ts-hist-tocs.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def init_plotting(w,h):
  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (w,h)
  plt.rcParams['font.size'] = 13
  plt.rcParams['font.family'] = 'OfficinaSanITCBoo'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']





# snapshots = pickle.load(open('results/hist-fit-fp/snapshots-fit-hist.pkl', 'rb'))
plot-color-ts.py 文件源码 项目:ptreeopt 作者: jdherman 项目源码 文件源码 阅读 70 收藏 0 点赞 0 评论 0
def init_plotting(w,h):
  sns.set_style('whitegrid')
  plt.rcParams['figure.figsize'] = (w,h)
  plt.rcParams['font.size'] = 13
  plt.rcParams['font.family'] = 'OfficinaSanITCBoo'
  # plt.rcParams['font.weight'] = 'bold'
  plt.rcParams['axes.labelsize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['axes.titlesize'] = 1.1*plt.rcParams['font.size']
  plt.rcParams['legend.fontsize'] = plt.rcParams['font.size']
  plt.rcParams['xtick.labelsize'] = plt.rcParams['font.size']
  plt.rcParams['ytick.labelsize'] = plt.rcParams['font.size']





# snapshots = pickle.load(open('results/hist-fit-fp/snapshots-fit-hist.pkl', 'rb'))
# snapshots = pickle.load(open('results/hist-tocs/snapshots-tocs-depth-3-seed-0.pkl', 'rb'))
pipeline.py 文件源码 项目:syracuse_public 作者: dssg 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def plot_predict_proba(y_pred_probs, clf, pdf=None):
    """Plots the predict proba distribution"""
    fig, ax = plt.subplots(1, figsize=(18, 8))
    sns.set_style("white")
    sns.set_context("poster",
                    font_scale=2.25,
                    rc={"lines.linewidth": 1.25, "lines.markersize": 8})
    sns.distplot(y_pred_probs)
    plt.xlabel('predict_proba')
    plt.ylabel('frequency')
    plt.title(clf + ' proba')
    if pdf:
        pdf.savefig()
        plt.close()
    else:
        plt.show()
histogram.py 文件源码 项目:astetik 作者: mikkokotila 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def histogram(data,variables):

    sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 0})

    sns.set_style('white')

    var_length = len(variables)

    fig, axes = plt.subplots(1, var_length, figsize=(19, 5))

    for i in range(var_length):

        axes[i].hist(data[variables[i]],lw=0,color="indianred",bins=8);
        axes[i].tick_params(axis='both', which='major', pad=15)
        axes[i].set_xlabel(variables[i])
        axes[i].set_yticklabels("");

    sns.despine(left=True)
test_pretrained_model.py 文件源码 项目:hco-experiments 作者: zooniverse 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def plot_pred_vs_image(img,preds_df,out_name):
    # function to plot predictions vs image
    f, axarr = plt.subplots(2, 1)
    plt.suptitle("ResNet50- PreTrained on ImageNet")
    axarr[0].imshow(img)
    sns.set_style("whitegrid")
    pl = sns.barplot(data = preds_df, x='Score', y='Species')
    axarr[1] = sns.barplot(data = preds_df, x='Score', y='Species',)
    axarr[0].autoscale(enable=False)
    axarr[0].get_xaxis().set_ticks([])
    axarr[0].get_yaxis().set_ticks([])
    axarr[1].autoscale(enable=False)
    gs = gridspec.GridSpec(2,1, width_ratios=[1],height_ratios=[1,0.1])
    plt.tight_layout()
    plt.savefig(out_name + '.png')


#########################
# Models
#########################

# load model
Art_class.py 文件源码 项目:artorithmia 作者: alichtner 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def extract_blur(self, plot=False):
        """
        Calculate the variance of the 2nd derivative of the image to get blur.

        Input:  plot (bool) whether or not to show the image after Laplacian
        Output: None"""
        # do on grayscale
        # check what the mean would give instead of variance
        self.bluriness = filters.laplace(color.rgb2gray(self.image)).var()
        if plot is True:
            sns.set_style("whitegrid", {'axes.grid': False})
            self.lap = filters.laplace(color.rgb2gray(self.image))
            plt.imshow(self.lap)
            plt.title('Laplacian of {}'.format(self.short_name))
            plt.show()
            plt.imshow(self.lap)
            plt.show()
art_plot.py 文件源码 项目:artorithmia 作者: alichtner 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def plot_hsv(image, bins=12):
    """
    Plot HSV histograms of image
    INPUT: image with HSV channels
    OUPUT: plot of HSV histograms and color spectrum
    """
    sns.set_style("whitegrid", {'axes.grid': False})
    fig = plt.figure(figsize=(12, 5))
    plt.subplots_adjust(top=2, bottom=1, wspace=.5, hspace=0)
    plt.subplot(231)
    plt.hist(image[:, :, 0].flatten(), bins=bins, color='gray')
    plt.title('Hue')
    plt.subplot(232)
    plt.hist(image[:, :, 1].flatten(), bins=bins, color='gray')
    plt.title('Saturation')
    plt.subplot(233)
    plt.hist(image[:, :, 2].flatten(), bins=bins, color='gray')
    plt.title('Value')
    plt.subplot(234)
    plt.imshow(all_hues, extent=(0, 1, 0, 0.2))
    plt.show()
chart.py 文件源码 项目:Penny-Dreadful-Tools 作者: PennyDreadfulMTG 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def image(path, costs):
    ys = ['0', '1', '2', '3', '4', '5', '6', '7+', 'X']
    xs = [costs.get(k, 0) for k in ys]
    sns.set_style('white')
    sns.set(font='Concourse C3', font_scale=3)
    g = sns.barplot(ys, xs, palette=['grey'] * len(ys))
    g.axes.yaxis.set_ticklabels([])
    rects = g.patches
    sns.set(font='Concourse C3', font_scale=2)
    for rect, label in zip(rects, xs):
        if label == 0:
            continue
        height = rect.get_height()
        g.text(rect.get_x() + rect.get_width()/2, height + 0.5, label, ha='center', va='bottom')
    g.margins(y=0, x=0)
    sns.despine(left=True, bottom=True)
    g.get_figure().savefig(path, transparent=True, pad_inches=0, bbox_inches='tight')
    plt.clf() # Clear all data from matplotlib so it does not persist across requests.
    return path
plotting.py 文件源码 项目:fitbit-analyzer 作者: 5agado 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def plotSleepValueHeatmap(intradayStats, sleepValue=1):
    sns.set_context("poster")
    sns.set_style("darkgrid")

    xTicksDiv = 20
    #stepSize = int(len(xticks)/xTicksDiv)
    stepSize = 60
    xticks = [x for x in intradayStats.columns.values]
    keptticks = xticks[::stepSize]
    xticks = ['' for _ in xticks]
    xticks[::stepSize] = keptticks
    plt.figure(figsize=(16, 4.2))
    g = sns.heatmap(intradayStats.loc[sleepValue].reshape(1,-1))
    g.set_xticklabels(xticks, rotation=45)
    g.set_yticklabels([])
    g.set_ylabel(sleepStats.SLEEP_VALUES[sleepValue])
    plt.tight_layout()
    sns.plt.show()
styling.py 文件源码 项目:cohorts 作者: hammerlab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def set_styling():
    sb.set_style("white")
    red = colors.hex2color("#bb3f3f")
    blue = colors.hex2color("#5a86ad")
    deep_colors = sb.color_palette("deep")
    green = deep_colors[1]
    custom_palette = [red, blue, green]
    custom_palette.extend(deep_colors[3:])
    sb.set_palette(custom_palette)
    mpl.rcParams.update({"figure.figsize": np.array([6, 6]),
                         "legend.fontsize": 12,
                         "font.size": 16,
                         "axes.labelsize": 16,
                         "axes.labelweight": "bold",
                         "xtick.labelsize": 16,
                         "ytick.labelsize": 16})
figs.py 文件源码 项目:extract 作者: dblalock 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def makeThickSine():
    sineNoiseStd = 0
    seqLen = 750
    squareLen = seqLen / 17.
    sineLen = int(squareLen * 4)
    sine1 = synth.sines(sineLen, noiseStd=sineNoiseStd)

    sb.set_style('white')
    _, ax = plt.subplots()
    ax.plot(sine1, lw=16)
    ax.set_xlim([-squareLen, len(sine1) + squareLen])
    ax.set_ylim([-2, 2])

    sb.despine(left=True)
    plt.show()

# def makeWeirdSine(squareLen, numSquares, sineNoiseStd, **kwargs):
#   firstQuarterFrac = .4
#   length = int(squareLen * numSquares)
#   firstQuarterLen = int(firstQuarterFrac * length)
    # sine1 = synth.sines(firstQuarterLen, periods=.25, **kwargs)
    # sine2 = synth.sines(firs)
    # sine2 = synth.warpedSine(sineLen, firstHalfFrac=.67,
    #       noiseStd=sineNoiseStd)
figs.py 文件源码 项目:extract 作者: dblalock 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def makeGarbageDimTs():
    np.random.seed(123)
    seqLen = 750
    squareLen = seqLen / 17.
    seq = synth.notSoRandomWalk(seqLen, std=.05,
        trendFilterLength=(seqLen // 2), lpfLength=2)

    sb.set_style('white')
    _, ax = plt.subplots()
    # color = sb.color_palette()[1]
    # ax.plot(seq, lw=4, color="#660000") # red I'm using in keynote
    ax.plot(seq, lw=4, color="#CC0000") # red I'm using in keynote
    ax.set_xlim([-squareLen, seqLen + squareLen])
    ax.set_ylim([np.min(seq) * 2, np.max(seq) * 2])

    sb.despine(left=True)
    plt.show()

# def makeMethodsWarpedTs():


# ================================================================ Better Fig1
vae_plots.py 文件源码 项目:pyro 作者: uber 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def plot_llk(train_elbo, test_elbo):
    import matplotlib.pyplot as plt
    import numpy as np
    import scipy as sp
    import seaborn as sns
    import pandas as pd
    plt.figure(figsize=(30, 10))
    sns.set_style("whitegrid")
    data = np.concatenate([np.arange(len(test_elbo))[:, sp.newaxis], -test_elbo[:, sp.newaxis]], axis=1)
    df = pd.DataFrame(data=data, columns=['Training Epoch', 'Test ELBO'])
    g = sns.FacetGrid(df, size=10, aspect=1.5)
    g.map(plt.scatter, "Training Epoch", "Test ELBO")
    g.map(plt.plot, "Training Epoch", "Test ELBO")
    plt.savefig('./vae_results/test_elbo_vae.png')
    plt.close('all')
sucess_dialogue_length.py 文件源码 项目:guesswhat 作者: GuessWhatGame 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __init__(self, path, games, logger, suffix):
        super(SuccessDialogueLength, self).__init__(path, self.__class__.__name__, suffix)

        status_list = []
        status_count = collections.defaultdict(int)
        length_list = []

        for game in games:

            length_list.append(len(game.questions))

            status_count[game.status] += 1
            status_list.append(game.status)


        success = np.array([s == "success" for s in status_list]) + 0
        failure = np.array([s == "failure" for s in status_list]) + 0
        incomp  = np.array([s == "incomplete" for s in status_list]) + 0

        sns.set_style("whitegrid", {"axes.grid": False})

        if sum(incomp) > 0:
            columns = ['Size of Dialogues', 'Success', 'Failure', 'Incomplete']
            data = np.array([length_list, success, failure, incomp]).transpose()
        else:
            columns = ['Size of Dialogues', 'Success', 'Failure']
            data = np.array([length_list, success, failure]).transpose()

        df = pd.DataFrame(data, columns=columns)
        df = df.convert_objects(convert_numeric=True)
        df = df.groupby('Size of Dialogues').sum()
        df = df.div(df.sum(axis=1), axis=0)
        #df = df.sort_values(by='Success')
        f = df.plot(kind="bar", stacked=True, width=1, alpha=0.3)

        f.set_xlim(-0.5,29.5)

        plt.xlabel("Size of Dialogues", {'size':'14'})
        plt.ylabel("Success ratio", {'size':'14'})
ulilz_CNN.py 文件源码 项目:QDREN 作者: andreamad8 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def plot_dist(train_y,dev_y,test_y):
    import seaborn as sns
    import matplotlib.pyplot as plt
    plt.rc('text', usetex=True)
    plt.rc('font', family='Times-Roman')
    sns.set_style(style='white')
    color = sns.color_palette("Set2", 10)
    fig = plt.figure(figsize=(8,12))

    ax1 = fig.add_subplot(3, 1, 1)
    # plt.title("Label distribution",fontsize=20)
    sns.distplot(train_y,kde=False,label='Training', hist=True, norm_hist=True,color="blue")
    ax1.set_xlabel("Answer")
    ax1.set_ylabel("Frequency")
    ax1.set_xlim([0,500])
    plt.legend(loc='best')

    ax2 = fig.add_subplot(3, 1, 2)
    sns.distplot(dev_y,kde=False,label='Validation', hist=True, norm_hist=True,color="green")
    ax2.set_xlabel("Answer")
    ax2.set_ylabel("Frequency")
    ax2.set_xlim([0,500])
    plt.legend(loc='best')

    ax3 = fig.add_subplot(3, 1, 3)
    sns.distplot(test_y,kde=False,label='Test', hist=True, norm_hist=True,color="red")
    ax3.set_xlabel("Answer")
    ax3.set_ylabel("Frequency")
    ax3.set_xlim([0,500])
    plt.legend(loc='best')



    plt.savefig('checkpoints/label_dist.pdf', format='pdf', dpi=300)

    plt.show()
UtilityFunctions.py 文件源码 项目:chainladder-python 作者: jbogaardt 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, my_dict):     
        sns.set_style("whitegrid")
        _ = plt.figure()
        grid_x = 1 if len(my_dict) == 1 else round(len(my_dict) / 2,0)
        grid_y = 1 if len(my_dict) == 1 else 2
        fig, ax = plt.subplots(figsize=(grid_y*15, grid_x*10))
        for num, item in enumerate(my_dict):
            _ = plt.subplot(grid_x,grid_y,num+1)
            self.__dict_plot(item)
stats.py 文件源码 项目:temci 作者: parttimenerd 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def reset_plt(self):
        """ Reset the current matplotlib plot style. """
        import matplotlib.pyplot as plt
        plt.gcf().subplots_adjust(bottom=0.15)
        if Settings()["report/xkcd_like_plots"]:
            import seaborn as sns
            sns.reset_defaults()
            mpl.use("agg")
            plt.xkcd()
        else:
            import seaborn as sns
            sns.reset_defaults()
            sns.set_style("darkgrid")
            sns.set_palette(sns.color_palette("muted"))
            mpl.use("agg")
pretraining.py 文件源码 项目:pandora 作者: mikekestemont 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def plot_mfi(self, outputfile='embeddings.pdf', nb_clusters=8, weights='NA'):
        # collect embeddings for mfi:
        X = np.asarray([self.w2v_model[w] for w in self.mfi \
                            if w in self.w2v_model], dtype='float32')
        # dimension reduction:
        tsne = TSNE(n_components=2)
        coor = tsne.fit_transform(X) # unsparsify

        plt.clf()
        sns.set_style('dark')
        sns.plt.rcParams['axes.linewidth'] = 0.4
        fig, ax1 = sns.plt.subplots()  

        labels = self.mfi
        # first plot slices:
        x1, x2 = coor[:,0], coor[:,1]
        ax1.scatter(x1, x2, 100, edgecolors='none', facecolors='none')
        # clustering on top (add some colouring):
        clustering = AgglomerativeClustering(linkage='ward',
                            affinity='euclidean', n_clusters=nb_clusters)
        clustering.fit(coor)
        # add names:
        for x, y, name, cluster_label in zip(x1, x2, labels, clustering.labels_):
            ax1.text(x, y, name, ha='center', va="center",
                     color=plt.cm.spectral(cluster_label / 10.),
                     fontdict={'family': 'Arial', 'size': 8})
        # control aesthetics:
        ax1.set_xlabel('')
        ax1.set_ylabel('')
        ax1.set_xticklabels([])
        ax1.set_xticks([])
        ax1.set_yticklabels([])
        ax1.set_yticks([])
        sns.plt.savefig(outputfile, bbox_inches=0)
script.py 文件源码 项目:Dataquest 作者: ustutz 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def main():
        seaborn_Seaborn_Module.set_style("dark")
        housing_2013 = pandas_Pandas_Module.read_csv("../Hud_2013.csv")
        cols = ['AGE1', 'FMR', 'TOTSAL']
        filtered_housing_2013 = housing_2013[cols]
        filtered_housing_2013.hist(column='AGE1', bins=5)
        filtered_housing_2013.hist(column='AGE1', bins=10)
        matplotlib_pyplot_Pyplot_Module.show()
script.py 文件源码 项目:Dataquest 作者: ustutz 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def main():
        seaborn_Seaborn_Module.set_style("dark")
        housing_2013 = pandas_Pandas_Module.read_csv("../Hud_2013.csv")
        cols = ['AGE1', 'FMR', 'TOTSAL']
        filtered_housing_2013 = housing_2013[cols]
        filtered_housing_2013.hist(column='FMR', bins=20)
        matplotlib_pyplot_Pyplot_Module.show()
plot.py 文件源码 项目:spotlight 作者: maciejkula 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def plot_results(model, movielens, amazon):

    sns.set_style("darkgrid")

    for name, result in (('Movielens',
                          movielens), ('Amazon', amazon)):

        print('Dataset: {}'.format(name))

        (compression_ratio,
         mrr,
         elapsed) = process_results(result, verbose=True)

        plt.plot(compression_ratio, mrr,
                 label=name)

    plt.ylabel("MRR ratio to baseline")
    plt.xlabel("Compression ratio")
    plt.title("Compression ratio vs MRR ratio")

    plt.legend(loc='lower right')
    plt.savefig('{}_plot.png'.format(model))
    plt.close()

    for name, result in (('Movielens',
                          movielens), ('Amazon', amazon)):

        (compression_ratio,
         mrr,
         elapsed) = process_results(result)

        plt.plot(compression_ratio, elapsed,
                 label=name)

    plt.ylabel("Time ratio to baseline")
    plt.xlabel("Compression ratio")
    plt.title("Compression ratio vs time ratio")
    plt.legend(loc='lower right')

    plt.savefig('{}_time.png'.format(model))
    plt.close()
information_value.py 文件源码 项目:score_card_base_python 作者: zzstrwolf 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def plot_br_chart(self,column):
        if type(self.woe_dicts[column].items()[0][0]) == str:
            woe_lists = sorted(self.woe_dicts[column].items(), key = self.sort_dict)
        else:
            woe_lists = sorted(self.woe_dicts[column].items(),key = lambda item:item[0])
        sns.set_style(rc={"axes.facecolor": "#EAEAF2",
                "axes.edgecolor": "#EAEAF2",
                "axes.linewidth": 1,
                "grid.color": "white",})
        tick_label = [i[0] for i in woe_lists]
        counts = [i[1][1] for i in woe_lists]
        br_data = [i[1][2] for i in woe_lists]
        x = range(len(counts))
        fig, ax1 = plt.subplots(figsize=(12,8))
        my_palette = sns.color_palette(n_colors=100)
        sns.barplot(x,counts,ax=ax1,palette=sns.husl_palette(n_colors=20,l=.7))
        plt.xticks(x,tick_label,rotation = 30,fontsize=12)
        plt.title(column,fontsize=18)
        ax1.set_ylabel('count',fontsize=15)
        ax1.tick_params('y',direction='in',length=6, width=0.5, labelsize=12)
        #ax1.bar(x,counts,tick_label = tick_label,color = 'y',align = 'center')
        #ax1.bar(x,counts,color = 'y',align = 'center')

        ax2 = ax1.twinx()
        ax2.plot(x,br_data,color='black')
        ax2.set_ylabel('bad rate',fontsize=15)
        ax2.tick_params('y',direction='in',length=6, width=0.5, labelsize=12)
        plot_margin = 0.25
        x0, x1, y0, y1 = ax1.axis()
        ax1.axis((x0 - plot_margin,
              x1 + plot_margin,
              y0 - 0,
              y1 * 1.1))
        plt.show()


问题


面经


文章

微信
公众号

扫码关注公众号