当前位置: 首页>>代码示例>>Python>>正文


Python pyplot.step方法代码示例

本文整理汇总了Python中matplotlib.pyplot.step方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.step方法的具体用法?Python pyplot.step怎么用?Python pyplot.step使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.step方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_precision_recall_curve

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def save_precision_recall_curve(eval_labels, pred_labels, average_precision, smell, config, out_folder, dim, method):
    fig = plt.figure()
    precision, recall, _ = precision_recall_curve(eval_labels, pred_labels)

    step_kwargs = ({'step': 'post'}
                   if 'step' in signature(plt.fill_between).parameters
                   else {})
    plt.step(recall, precision, color='b', alpha=0.2,
             where='post')
    plt.fill_between(recall, precision, alpha=0.2, color='b', **step_kwargs)

    plt.xlabel('Recall')
    plt.ylabel('Precision')
    plt.ylim([0.0, 1.05])
    plt.xlim([0.0, 1.0])
    if isinstance(config, cfg.CNN_config):
        title_str = smell + " (" + method + " - " + dim + ") - L=" + str(config.layers) + ", E=" + str(config.epochs) + ", F=" + str(config.filters) + \
                    ", K=" + str(config.kernel) + ", PW=" + str(config.pooling_window) + ", AP={0:0.2f}".format(average_precision)
    # plt.title(title_str)
    # plt.show()
    file_name = get_plot_file_name(smell, config, out_folder, dim, method, "_prc_")
    fig.savefig(file_name) 
开发者ID:tushartushar,项目名称:DeepLearningSmells,代码行数:24,代码来源:plot_util.py

示例2: draw

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def draw(num,zw_dict,maxb):
	"""
		draw the survival rate curve
	"""
	b_full_data=[]

	for i in range(1,maxb+1):
		b_full_data.append(win_prob(i,zw_dict))

	s=range(1,maxb+1)
	A,=plt.step(s, b_full_data, 'r-',where='post',label=num,linewidth=1.0)
	font1 = {'family' : 'Times New Roman',
	'weight' : 'normal',
	'size'   : 10,
	}

	tmp_data=np.array(b_full_data)
	tmp_data=1-tmp_data

	legend = plt.legend(handles=[A],prop=font1)
	plt.ylim((0,1))
	
	plt.savefig(save_path+"/km_"+num)
	plt.close(1) 
开发者ID:rk2900,项目名称:DLF,代码行数:26,代码来源:km.py

示例3: plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def plot(dashed=False):
    print(hyperparams.methodEvalString())

    _, true_inl, _, _, _ = cache.getOrEval()

    true_inl = sorted(true_inl)
    mscores = np.array(true_inl, dtype=float) / float(hyperparams.methodNPts())

    yax = np.arange(len(mscores)).astype(float) / len(mscores)

    if dashed:
        style = '--'
    else:
        style = '-'

    plt.step(mscores, np.flip(yax), linestyle=style,
             label='%s: %.02f' % (hyperparams.label(), np.mean(mscores)),
             color=hyperparams.methodColor()) 
开发者ID:uzh-rpg,项目名称:imips_open,代码行数:20,代码来源:plot_match_distrib.py

示例4: plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def plot(do_plot=True):
    hyperparams.announceEval()
    succ, Rerr, terr = cache_forward_pass.loadOrEvaluate()
    assert Rerr is not None
    sx, sy = evaluate.lessThanCurve(succ)
    sauc = evaluate.auc(sx, sy, 200)
    rx, ry = evaluate.lessThanCurve(Rerr)
    if FLAGS.ds == 'eu':
        print('5 degrees')
        rmax = 5
    else:
        rmax = 1
    rauc = evaluate.auc(rx, ry, rmax)
    tx, ty = evaluate.lessThanCurve(terr)
    tauc = evaluate.auc(tx, ty, 1)

    if do_plot:
        plt.step(
            rx, ry, label='%s R: %.2f' % (hyperparams.methodString(), rauc))
        plt.step(
            tx, ty, label='%s t: %.2f' % (hyperparams.methodString(), tauc))
    return sauc, rauc, tauc 
开发者ID:uzh-rpg,项目名称:sips2_open,代码行数:24,代码来源:plot_pose_accuracy.py

示例5: plot_PR_curve

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def plot_PR_curve(classifier):
    
    precision, recall, thresholds = precision_recall_curve(DataPrep.test_news['Label'], classifier)
    average_precision = average_precision_score(DataPrep.test_news['Label'], classifier)
    
    plt.step(recall, precision, color='b', alpha=0.2,
             where='post')
    plt.fill_between(recall, precision, step='post', alpha=0.2,
                     color='b')
    
    plt.xlabel('Recall')
    plt.ylabel('Precision')
    plt.ylim([0.0, 1.05])
    plt.xlim([0.0, 1.0])
    plt.title('2-class Random Forest Precision-Recall curve: AP={0:0.2f}'.format(
              average_precision)) 
开发者ID:nishitpatel01,项目名称:Fake_News_Detection,代码行数:18,代码来源:classifier.py

示例6: plot_multi_agg_pr_curves

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def plot_multi_agg_pr_curves(line_name2pr_list, plot_title='Aggregated Precision-Recall Curve',
                             figsize=(12, 8), xlim=(0, 1), ylim=(0, 1), basic_font_size=14):
    plt.figure(figsize=figsize)

    for line_name, (prec_list, recall_list) in line_name2pr_list.items():
        plt.step(recall_list, prec_list, label=line_name)

    plt.legend(fontsize=basic_font_size)
    plt.title(plot_title, fontsize=basic_font_size+ 2)
    plt.xlabel('Recall', fontsize=basic_font_size)
    plt.ylabel('Precision', fontsize=basic_font_size)
    plt.xticks(fontsize=basic_font_size)
    plt.yticks(fontsize=basic_font_size)
    plt.grid(True)
    plt.xlim(xlim)
    plt.ylim(ylim) 
开发者ID:thunlp,项目名称:DIAG-NRE,代码行数:18,代码来源:utils.py

示例7: plot_trajectory

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def plot_trajectory(plot_data, instance_name, metric_name, font_size, do_label_rename, plt, plot_individual, plot_markers, plot_type):
    for label, d in plot_data.items():

        if do_label_rename:
            label = label_rename(label)
        
        if plot_individual and d["individual_trajectories"] and d["individual_times_finished"]:
            for individual_trajectory, individual_times_finished in zip(d["individual_trajectories"], d["individual_times_finished"]):
                plt.step(individual_times_finished, individual_trajectory, color=d["color"], where='post', linestyle=":", marker="x" if plot_markers else None)
        
        plt.step(d["finishing_times"], d["center"], color=d["color"], label=label, where='post', linestyle=d["linestyle"], marker="o" if plot_markers else None)
        plt.fill_between(d["finishing_times"], d["lower"], d["upper"], step="post", color=[(d["color"][0], d["color"][1], d["color"][2], 0.5)])
    plt.xlabel('wall clock time [s]', fontsize=font_size)
    plt.ylabel('incumbent %s %s' % (metric_name, plot_type), fontsize=font_size)
    plt.legend(loc='best', prop={'size': font_size})
    plt.title(instance_name, fontsize=font_size) 
开发者ID:automl,项目名称:Auto-PyTorch,代码行数:18,代码来源:plot_trajectories.py

示例8: __call__

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def __call__(self, args, env):

        import numpy as np
        import matplotlib.pyplot as plt
        from sklearn.metrics import average_precision_score
        from sklearn.metrics import precision_recall_curve
        from vergeml.plots import load_labels, load_predictions

        try:
            labels = load_labels(env)
        except FileNotFoundError:
            raise VergeMLError("Can't plot PR curve - not supported by model.")

        nclasses = len(labels)
        if args['class'] not in labels:
            raise VergeMLError("Unknown class: " + args['class'])

        try:
            y_test, y_score = load_predictions(env, nclasses)
        except FileNotFoundError:
            raise VergeMLError("Can't plot PR curve - not supported by model.")

        # From:
        # https://scikit-learn.org/stable/auto_examples/model_selection/plot_precision_recall.html#sphx-glr-auto-examples-model-selection-plot-precision-recall-py

        ix = labels.index(args['class'])
        y_test = y_test[:,ix].astype(np.int)
        y_score = y_score[:,ix]

        precision, recall, _ = precision_recall_curve(y_test, y_score)
        average_precision = average_precision_score(y_test, y_score)

        plt.step(recall, precision, color='b', alpha=0.2, where='post')
        plt.fill_between(recall, precision, alpha=0.2, color='b', step='post')

        plt.xlabel('Recall ({})'.format(args['class']))
        plt.ylabel('Precision ({})'.format(args['class']))
        plt.ylim([0.0, 1.05])
        plt.xlim([0.0, 1.0])
        plt.title('Precision-Recall curve for @{0}: AP={1:0.2f}'.format(args['@AI'], average_precision))
        plt.show() 
开发者ID:mme,项目名称:vergeml,代码行数:43,代码来源:pr.py

示例9: plot_pr_curve

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def plot_pr_curve(y, p):
    precision, recall, _ = precision_recall_curve(y, p)

    plt.step(recall, precision, color='b', alpha=0.2, where='post')
    plt.fill_between(recall, precision, step='post', alpha=0.2, color='b')
    plt.xlabel('Recall')
    plt.ylabel('Precision')
    plt.ylim([0.0, 1.05])
    plt.xlim([0.0, 1.0]) 
开发者ID:jeongyoonlee,项目名称:Kaggler,代码行数:11,代码来源:classification.py

示例10: plot_pr_curve

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def plot_pr_curve(precisions, recalls, out_image, title):
  plt.step(recalls, precisions, color='b', alpha=0.2, where='post')
  plt.fill_between(recalls, precisions, step='post', alpha=0.2, color='b')
  plt.xlabel('Recall')
  plt.ylabel('Precision')
  plt.xlim([0.0, 1.05])
  plt.ylim([0.0, 1.05])
  plt.title(title)
  plt.savefig(out_image)
  plt.clf() 
开发者ID:deepset-ai,项目名称:FARM,代码行数:12,代码来源:squad_evaluation.py

示例11: __init__

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def __init__(self, x, side='right'):
        step = True
        if step: #TODO: make this an arg and have a linear interpolation option?
            x = np.array(x, copy=True)
            x.sort()
            nobs = len(x)
            y = np.linspace(1./nobs,1,nobs)
            super(ECDF, self).__init__(x, y, side=side, sorted=True)
        else:
            return interp1d(x,y,drop_errors=False,fill_values=ival) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:12,代码来源:empirical_distribution.py

示例12: do_prc

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def do_prc(scores, true_labels, file_name='', directory='', plot=True):
    """ Does the PRC curve

    Args :
            scores (list): list of scores from the decision function
            true_labels (list): list of labels associated to the scores
            file_name (str): name of the PRC curve
            directory (str): directory to save the jpg file
            plot (bool): plots the PRC curve or not
    Returns:
            prc_auc (float): area under the under the PRC curve
    """
    precision, recall, thresholds = precision_recall_curve(true_labels, scores)
    prc_auc = auc(recall, precision)

    if plot:
        plt.figure()
        plt.step(recall, precision, color='b', alpha=0.2, where='post')
        plt.fill_between(recall, precision, step='post', alpha=0.2, color='b')
        plt.xlabel('Recall')
        plt.ylabel('Precision')
        plt.ylim([0.0, 1.05])
        plt.xlim([0.0, 1.0])
        plt.title('Precision-Recall curve: AUC=%0.4f' 
                            %(prc_auc))
        if not os.path.exists(directory):
            os.makedirs(directory)
        plt.savefig('results/' + file_name + '_prc.jpg')
        plt.close()

    return prc_auc 
开发者ID:houssamzenati,项目名称:Efficient-GAN-Anomaly-Detection,代码行数:33,代码来源:evaluations.py

示例13: plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def plot(label=None, k=10):
    hyperparams.announceEval()
    eval_pairs = hyperparams.getEvalDataGen()
    # Very special case lfnet:
    if FLAGS.baseline == 'lfnet':
        x = [50, 100, 150]
        y = []
        for num_pts in x:
            forward_pass_dict = baselines.parseLFNetOuts(eval_pairs, num_pts)
            success = np.zeros(len(eval_pairs), dtype=bool)
            for pair_i in range(len(eval_pairs)):
                pair = eval_pairs[pair_i]
                folder, a, b = pair.name().split(' ')
                forward_passes = [forward_pass_dict['%s%s' % (folder, i)]
                                  for i in [a, b]]

                matched_indices = system.match(forward_passes)
                inliers = system.getInliers(
                    pair, forward_passes, matched_indices)
                if np.count_nonzero(inliers) >= k:
                    success[pair_i] = True
            y.append(np.mean(success.astype(float)))
        plt.plot(x, y, 'x', label='%s: N/A' % (hyperparams.methodString()))
    else:
        pair_outs = cache_forward_pass.loadOrCalculateOuts()
        if FLAGS.num_scales > 1 and FLAGS.baseline == '':
            fps = [[multiscale.forwardPassFromHicklable(im) for im in pair]
                   for pair in pair_outs]
        else:
            fps = [[system.forwardPassFromHicklable(im) for im in pair]
                   for pair in pair_outs]
        pairs_fps = zip(eval_pairs, fps)
        stats = [evaluate.leastNumForKInliers(pair_fps[0], pair_fps[1], k)
                 for pair_fps in pairs_fps]
        x, y = evaluate.lessThanCurve(stats)
        auc = evaluate.auc(x, y, 200)

        plt.step(x, y, label='%s: %.2f' % (hyperparams.label(), auc))
        return auc 
开发者ID:uzh-rpg,项目名称:sips2_open,代码行数:41,代码来源:plot_results.py

示例14: ecdf_plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def ecdf_plot(self):
        """Generate ECDF plot comparing distributions of the test classes."""
        plt.figure()
        for classname in self.data:
            data = self.data.loc[:, classname]
            levels = np.linspace(1. / len(data), 1, len(data))
            plt.step(sorted(data), levels, where='post')
        self.make_legend()
        plt.title("Empirical Cumulative Distribution Function")
        plt.xlabel("Time [s]")
        plt.ylabel("Cumulative probability")
        plt.savefig(join(self.output, "ecdf_plot.png"), bbox_inches="tight")
        plt.close() 
开发者ID:tomato42,项目名称:tlsfuzzer,代码行数:15,代码来源:analysis.py

示例15: plot_pr_curve

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import step [as 别名]
def plot_pr_curve(precisions, recalls, out_image, title):
    plt.step(recalls, precisions, color='b', alpha=0.2, where='post')
    plt.fill_between(recalls, precisions, step='post', alpha=0.2, color='b')
    plt.xlabel('Recall')
    plt.ylabel('Precision')
    plt.xlim([0.0, 1.05])
    plt.ylim([0.0, 1.05])
    plt.title(title)
    plt.savefig(out_image)
    plt.clf() 
开发者ID:easonnie,项目名称:semanticRetrievalMRS,代码行数:12,代码来源:squad_eval_v1.py


注:本文中的matplotlib.pyplot.step方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。