MCPcopy Create free account
hub / github.com/catboost/catboost / save_plot_file

Function save_plot_file

catboost/python-package/catboost/plot_helpers.py:24–56  ·  view source on GitHub ↗
(plot_file, plot_name, figs)

Source from the content-addressed store, hash-verified

22
23
24def save_plot_file(plot_file, plot_name, figs):
25 warn_msg = "To draw plots you should install plotly."
26 try:
27 from plotly.offline import plot as plotly_plot
28 except ImportError as e:
29 warnings.warn(warn_msg)
30 raise ImportError(str(e))
31
32 def write_plot_file(plot_file_stream):
33 plot_file_stream.write('\n'.join((
34 '<html>',
35 '<head>',
36 '<meta charset="utf-8" />',
37 '<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>',
38 '<title>{}</title>'.format(plot_name),
39 '</head>',
40 '<body>'
41 )))
42 for fig in figs:
43 graph_div = plotly_plot(
44 fig,
45 output_type='div',
46 show_link=False,
47 include_plotlyjs=False
48 )
49 plot_file_stream.write('\n{}\n'.format(graph_div))
50 plot_file_stream.write('</body>\n</html>')
51
52 if isinstance(plot_file, str):
53 with open(fspath(plot_file), 'w') as plot_file_stream:
54 write_plot_file(plot_file_stream)
55 else:
56 write_plot_file(plot_file)
57
58
59class OfflineMetricVisualizer(object):

Callers 4

plot_predictionsMethod · 0.85
save_to_fileMethod · 0.85

Calls 4

isinstanceFunction · 0.85
write_plot_fileFunction · 0.85
strClass · 0.50
openFunction · 0.50

Tested by

no test coverage detected