Commit bcd77003 authored by JiechengZhao's avatar JiechengZhao Committed by Guolin Ke
Browse files

[python] use raw string to show label (#1274)

parent b0d2f826
...@@ -274,10 +274,10 @@ def _to_graphviz(tree_info, show_info, feature_names, ...@@ -274,10 +274,10 @@ def _to_graphviz(tree_info, show_info, feature_names,
label = 'split_feature_name:' + str(feature_names[root['split_feature']]) label = 'split_feature_name:' + str(feature_names[root['split_feature']])
else: else:
label = 'split_feature_index:' + str(root['split_feature']) label = 'split_feature_index:' + str(root['split_feature'])
label += '\nthreshold:' + str(root['threshold']) label += r'\nthreshold:' + str(root['threshold'])
for info in show_info: for info in show_info:
if info in {'split_gain', 'internal_value', 'internal_count'}: if info in {'split_gain', 'internal_value', 'internal_count'}:
label += '\n' + info + ':' + str(root[info]) label += r'\n' + info + ':' + str(root[info])
graph.node(name, label=label) graph.node(name, label=label)
if root['decision_type'] == '<=': if root['decision_type'] == '<=':
l_dec, r_dec = '<=', '>' l_dec, r_dec = '<=', '>'
...@@ -290,9 +290,9 @@ def _to_graphviz(tree_info, show_info, feature_names, ...@@ -290,9 +290,9 @@ def _to_graphviz(tree_info, show_info, feature_names,
else: # leaf else: # leaf
name = 'leaf' + str(root['leaf_index']) name = 'leaf' + str(root['leaf_index'])
label = 'leaf_index:' + str(root['leaf_index']) label = 'leaf_index:' + str(root['leaf_index'])
label += '\nleaf_value:' + str(root['leaf_value']) label += r'\nleaf_value:' + str(root['leaf_value'])
if 'leaf_count' in show_info: if 'leaf_count' in show_info:
label += '\nleaf_count:' + str(root['leaf_count']) label += r'\nleaf_count:' + str(root['leaf_count'])
graph.node(name, label=label) graph.node(name, label=label)
if parent is not None: if parent is not None:
graph.edge(parent, name, decision) graph.edge(parent, name, decision)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment