-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Export_graphviz() defaults "Helvetica" font #14290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
34cd59d
Export_graphviz() defaults "Helvetica" font
wstates 316127c
Export_graphviz() defaults "Helvetica" font
wstates ab7f01e
Merge branch 'test' of https://github.com/wstates/scikit-learn into test
wstates cd95f9a
Merge branch 'test' of https://github.com/wstates/scikit-learn into test
wstates 41176db
Merge branch 'test' of https://github.com/wstates/scikit-learn into test
wstates 9170f34
Merge branch 'test' of https://github.com/wstates/scikit-learn into test
wstates 8ea2a51
Merge branch 'test' of https://github.com/wstates/scikit-learn into test
wstates 07f8d02
Merge branch 'test' of https://github.com/wstates/scikit-learn into test
wstates 5a59564
Merge branch 'test' of https://github.com/wstates/scikit-learn into test
wstates b052725
Modify Description
wstates 89b23f3
Merge branch 'test' of https://github.com/wstates/scikit-learn into test
wstates File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -183,7 +183,7 @@ def __init__(self, max_depth=None, feature_names=None, | |||||
class_names=None, label='all', filled=False, | ||||||
impurity=True, node_ids=False, | ||||||
proportion=False, rotate=False, rounded=False, | ||||||
precision=3, fontsize=None): | ||||||
precision=3, fontsize=None, fontname='helvetica'): | ||||||
self.max_depth = max_depth | ||||||
self.feature_names = feature_names | ||||||
self.class_names = class_names | ||||||
|
@@ -196,6 +196,7 @@ def __init__(self, max_depth=None, feature_names=None, | |||||
self.rounded = rounded | ||||||
self.precision = precision | ||||||
self.fontsize = fontsize | ||||||
self.fontname = fontname | ||||||
|
||||||
def get_color(self, value): | ||||||
# Find the appropriate color & intensity for a node | ||||||
|
@@ -355,15 +356,15 @@ def __init__(self, out_file=SENTINEL, max_depth=None, | |||||
feature_names=None, class_names=None, label='all', | ||||||
filled=False, leaves_parallel=False, impurity=True, | ||||||
node_ids=False, proportion=False, rotate=False, rounded=False, | ||||||
special_characters=False, precision=3): | ||||||
special_characters=False, precision=3, fontname='helvetica'): | ||||||
|
||||||
super().__init__( | ||||||
max_depth=max_depth, feature_names=feature_names, | ||||||
class_names=class_names, label=label, filled=filled, | ||||||
impurity=impurity, | ||||||
node_ids=node_ids, proportion=proportion, rotate=rotate, | ||||||
rounded=rounded, | ||||||
precision=precision) | ||||||
precision=precision, fontname=fontname) | ||||||
self.leaves_parallel = leaves_parallel | ||||||
self.out_file = out_file | ||||||
self.special_characters = special_characters | ||||||
|
@@ -434,15 +435,15 @@ def head(self): | |||||
', style="%s", color="black"' | ||||||
% ", ".join(rounded_filled)) | ||||||
if self.rounded: | ||||||
self.out_file.write(', fontname=helvetica') | ||||||
self.out_file.write(', fontname=%s' % self.fontname) | ||||||
self.out_file.write('] ;\n') | ||||||
|
||||||
# Specify graph & edge aesthetics | ||||||
if self.leaves_parallel: | ||||||
self.out_file.write( | ||||||
'graph [ranksep=equally, splines=polyline] ;\n') | ||||||
if self.rounded: | ||||||
self.out_file.write('edge [fontname=helvetica] ;\n') | ||||||
self.out_file.write('edge [fontname=%s] ;\n' % self.fontname) | ||||||
if self.rotate: | ||||||
self.out_file.write('rankdir=LR ;\n') | ||||||
|
||||||
|
@@ -656,7 +657,8 @@ def export_graphviz(decision_tree, out_file=None, max_depth=None, | |||||
feature_names=None, class_names=None, label='all', | ||||||
filled=False, leaves_parallel=False, impurity=True, | ||||||
node_ids=False, proportion=False, rotate=False, | ||||||
rounded=False, special_characters=False, precision=3): | ||||||
rounded=False, special_characters=False, precision=3, | ||||||
fontname='helvetica'): | ||||||
"""Export a decision tree in DOT format. | ||||||
|
||||||
This function generates a GraphViz representation of the decision tree, | ||||||
|
@@ -733,6 +735,9 @@ def export_graphviz(decision_tree, out_file=None, max_depth=None, | |||||
Number of digits of precision for floating point in the values of | ||||||
impurity, threshold and value attributes of each node. | ||||||
|
||||||
fontname : str,optional (default='helvetica') | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wstates could you accept this suggestion |
||||||
Set output dot file font. if there is a font error, try using "sans" | ||||||
|
||||||
Returns | ||||||
------- | ||||||
dot_data : string | ||||||
|
@@ -772,7 +777,7 @@ def export_graphviz(decision_tree, out_file=None, max_depth=None, | |||||
filled=filled, leaves_parallel=leaves_parallel, impurity=impurity, | ||||||
node_ids=node_ids, proportion=proportion, rotate=rotate, | ||||||
rounded=rounded, special_characters=special_characters, | ||||||
precision=precision) | ||||||
precision=precision, fontname=fontname) | ||||||
exporter.export(decision_tree) | ||||||
|
||||||
if return_string: | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add it to the docstring above