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


Python io.save方法代码示例

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


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

示例1: plot

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def plot(self, x, y, title=None, xlabel=None, ylabel=None,
             width=800, height=400, colors=None, line_width=2,
             tools='pan,box_zoom,wheel_zoom,box_select,hover,reset,save'):
        xlabel = xlabel or x
        f = figure(title=title, tools=tools,
                   width=width, height=height,
                   x_axis_label=xlabel or x,
                   y_axis_label=ylabel or '')
        if colors is not None:
            colors = iter(colors)
        else:
            colors = cycle(colors_palette)
        for yi in y:
            f.line(self.results[x], self.results[yi],
                   line_width=line_width,
                   line_color=next(colors), legend=yi)
        self.figures.append(f) 
开发者ID:miliadis,项目名称:DeepVideoCS,代码行数:19,代码来源:log.py

示例2: test_plot_time_series_with_large_initial_values

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def test_plot_time_series_with_large_initial_values():
    cds = ColumnDataSource({"y": [2e17, 1e16, 1e5], "x": [1, 2, 3]})
    title = "Are large initial values shown?"
    fig = monitoring._plot_time_series(data=cds, y_keys=["y"], x_name="x", title=title)
    title = "Test _plot_time_series can handle large initial values."
    output_file("time_series_initial_value.html", title=title)
    path = save(obj=fig)
    webbrowser.open_new_tab("file://" + path) 
开发者ID:OpenSourceEconomics,项目名称:estimagic,代码行数:10,代码来源:test_monitoring_app.py

示例3: main

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def main():
    args = parser.parse_args()
    title = 'comparison: ' + ','.join(args.experiments)
    x_axis_type = 'linear'
    y_axis_type = 'linear'
    width = 800
    height = 400
    line_width = 2
    tools = 'pan,box_zoom,wheel_zoom,box_select,hover,reset,save'
    results = {}
    for i, exp in enumerate(args.experiments):
        if args.legend is not None and len(args.legend) > i:
            name = args.legend[i]
        else:
            name = exp
        filename = exp + '/results.csv'
        results[name] = pd.read_csv(filename, index_col=None)
    figures = []
    for comp in args.compare:
        fig = figure(title=comp, tools=tools,
                     width=width, height=height,
                     x_axis_label=args.x_axis,
                     y_axis_label=comp,
                     x_axis_type=x_axis_type,
                     y_axis_type=y_axis_type)
        colors = cycle(args.colors)
        for i, (name, result) in enumerate(results.items()):
            fig.line(result[args.x_axis], result[comp],
                     line_width=line_width,
                     line_color=next(colors), legend=name)
        fig.legend.click_policy = "hide"
        figures.append(fig)

    plots = column(*figures)
    show(plots) 
开发者ID:eladhoffer,项目名称:convNet.pytorch,代码行数:37,代码来源:compare_experiments.py

示例4: save

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def save(self, title='Training Results'):
        if len(self.figures) > 0:
            if os.path.isfile(self.plot_path):
                os.remove(self.plot_path)
            output_file(self.plot_path, title=title)
            plot = column(*self.figures)
            save(plot)
            self.figures = []
        self.results.to_csv(self.path, index=False, index_label=False) 
开发者ID:eladhoffer,项目名称:bigBatch,代码行数:11,代码来源:utils.py

示例5: save_checkpoint

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def save_checkpoint(state, is_best, path='.', filename='checkpoint.pth.tar', save_all=False):
    filename = os.path.join(path, filename)
    torch.save(state, filename)
    if is_best:
        shutil.copyfile(filename, os.path.join(path, 'model_best.pth.tar'))
    if save_all:
        shutil.copyfile(filename, os.path.join(
            path, 'checkpoint_epoch_%s.pth.tar' % state['epoch'])) 
开发者ID:eladhoffer,项目名称:bigBatch,代码行数:10,代码来源:utils.py

示例6: save

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def save(plot,fname):    
    #SaveTool https://github.com/bokeh/bokeh/blob/118b6a765ee79232b1fef0e82ed968a9dbb0e17f/examples/models/line.py
    from bokeh.io import save, output_file
    output_file(fname)
    save(plot) 
开发者ID:histogrammar,项目名称:histogrammar-python,代码行数:7,代码来源:bokeh.py

示例7: save

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def save(self, title='Training Results'):
        if len(self.figures) > 0:
            if os.path.isfile(self.plot_path):
                os.remove(self.plot_path)
            output_file(self.plot_path, title=title)
            plot = column(*self.figures)
            save(plot)
            self.clear()
        self.results.to_csv(self.path, index=False, index_label=False) 
开发者ID:miliadis,项目名称:DeepVideoCS,代码行数:11,代码来源:log.py

示例8: results_add

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def results_add(epoch, results, train_loss, psnr):

    results.add(epoch=epoch + 1, train_loss=train_loss,
                psnr=psnr)
    results.plot(x='epoch', y=['train_loss'],
                 title='Loss', ylabel='loss')
    results.plot(x='epoch', y=['psnr'],
                 title='PSNR', ylabel='psnr')

    results.save() 
开发者ID:miliadis,项目名称:DeepVideoCS,代码行数:12,代码来源:log.py

示例9: draw_rec_prec

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def draw_rec_prec(rec, prec, mrec, mprec, class_name, ap):
    """
     Draw plot
    """
    plt.plot(rec, prec, '-o')
    # add a new penultimate point to the list (mrec[-2], 0.0)
    # since the last line segment (and respective area) do not affect the AP value
    area_under_curve_x = mrec[:-1] + [mrec[-2]] + [mrec[-1]]
    area_under_curve_y = mprec[:-1] + [0.0] + [mprec[-1]]
    plt.fill_between(area_under_curve_x, 0, area_under_curve_y, alpha=0.2, edgecolor='r')
    # set window title
    fig = plt.gcf() # gcf - get current figure
    fig.canvas.set_window_title('AP ' + class_name)
    # set plot title
    plt.title('class: ' + class_name + ' AP = {}%'.format(ap*100))
    #plt.suptitle('This is a somewhat long figure title', fontsize=16)
    # set axis titles
    plt.xlabel('Recall')
    plt.ylabel('Precision')
    # optional - set axes
    axes = plt.gca() # gca - get current axes
    axes.set_xlim([0.0,1.0])
    axes.set_ylim([0.0,1.05]) # .05 to give some extra space
    # Alternative option -> wait for button to be pressed
    #while not plt.waitforbuttonpress(): pass # wait for key display
    # Alternative option -> normal display
    #plt.show()
    # save the plot
    rec_prec_plot_path = os.path.join('result','classes')
    os.makedirs(rec_prec_plot_path, exist_ok=True)
    fig.savefig(os.path.join(rec_prec_plot_path, class_name + ".png"))
    plt.cla() # clear axes for next plot 
开发者ID:david8862,项目名称:keras-YOLOv3-model-set,代码行数:34,代码来源:eval.py

示例10: generate_rec_prec_html

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def generate_rec_prec_html(mrec, mprec, scores, class_name, ap):
    """
     generate dynamic P-R curve HTML page for each class
    """
    rec_prec_plot_path = os.path.join('result' ,'classes')
    os.makedirs(rec_prec_plot_path, exist_ok=True)
    bokeh_io.output_file(os.path.join(rec_prec_plot_path, class_name + '.html'), title='P-R curve for ' + class_name)

    # prepare curve data
    area_under_curve_x = mrec[:-1] + [mrec[-2]] + [mrec[-1]]
    area_under_curve_y = mprec[:-1] + [0.0] + [mprec[-1]]
    score_on_curve = [0.0] + scores[:-1] + [0.0] + [scores[-1]] + [1.0]
    source = bokeh.models.ColumnDataSource(data={
      'rec'      : area_under_curve_x,
      'prec' : area_under_curve_y,
      'score' : score_on_curve,
    })

    # prepare plot figure
    plt_title = 'class: ' + class_name + ' AP = {}%'.format(ap*100)
    plt = bokeh_plotting.figure(plot_height=200 ,plot_width=200, tools="", toolbar_location=None,
               title=plt_title, sizing_mode="scale_width")
    plt.background_fill_color = "#f5f5f5"
    plt.grid.grid_line_color = "white"
    plt.xaxis.axis_label = 'Recall'
    plt.yaxis.axis_label = 'Precision'
    plt.axis.axis_line_color = None

    # draw curve data
    plt.line(x='rec', y='prec', line_width=2, color='#ebbd5b', source=source)
    plt.add_tools(bokeh.models.HoverTool(
      tooltips=[
        ( 'score', '@score{0.0000 a}'),
      ],
      formatters={
        'rec'      : 'printf',
        'prec' : 'printf',
      },
      mode='vline'
    ))
    bokeh_io.save(plt) 
开发者ID:david8862,项目名称:keras-YOLOv3-model-set,代码行数:43,代码来源:eval.py

示例11: plot_comparison

# 需要导入模块: from bokeh import io [as 别名]
# 或者: from bokeh.io import save [as 别名]
def plot_comparison(experiments,
                    figure=None,
                    line_options=None,
                    title=None,
                    x_axis_label=None,
                    y_axis_label=None,
                    x_axis_type='linear',
                    y_axis_type='linear',
                    x_range=None,
                    y_range=None,
                    width=800,
                    height=400,
                    legend_text_font_size=None,
                    tools='pan,box_zoom,wheel_zoom,box_select,hover,reset,save',
                    figure_fn=bk_figure):
    line_options = line_options or multi_line_opts(len(experiments))
    if len(line_options) < len(experiments):
        line_options += multi_line_opts(len(experiments) -
                                        len(line_options))
    if figure is None:
        figure = figure_fn(title=title, tools=tools,
                           width=width, height=height,
                           x_axis_label=x_axis_label,
                           y_axis_label=y_axis_label,
                           x_axis_type=x_axis_type,
                           y_axis_type=y_axis_type,
                           x_range=x_range,
                           y_range=y_range)
    plotted = False
    for i, (name, result) in enumerate(experiments.items()):
        if result is None or len(result) == 0:
            continue
        result_x, result_y = zip(*result)
        figure.line(result_x, result_y, legend=name, **line_options[i])
        plotted = True
    if plotted:
        figure.legend.click_policy = "hide"
        if legend_text_font_size is not None:
            figure.legend.label_text_font_size = legend_text_font_size
    else:
        figure = None
    return figure 
开发者ID:eladhoffer,项目名称:convNet.pytorch,代码行数:44,代码来源:probe.py


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