@@ -33,7 +33,8 @@ def test_graphviz_toy():
33
33
# Test export code
34
34
contents1 = export_graphviz (clf , out_file = None )
35
35
contents2 = 'digraph Tree {\n ' \
36
- 'node [shape=box] ;\n ' \
36
+ 'node [shape=box, fontname="helvetica"] ;\n ' \
37
+ 'edge [fontname="helvetica"] ;\n ' \
37
38
'0 [label="X[0] <= 0.0\\ ngini = 0.5\\ nsamples = 6\\ n' \
38
39
'value = [3, 3]"] ;\n ' \
39
40
'1 [label="gini = 0.0\\ nsamples = 3\\ nvalue = [3, 0]"] ;\n ' \
@@ -50,7 +51,8 @@ def test_graphviz_toy():
50
51
contents1 = export_graphviz (clf , feature_names = ["feature0" , "feature1" ],
51
52
out_file = None )
52
53
contents2 = 'digraph Tree {\n ' \
53
- 'node [shape=box] ;\n ' \
54
+ 'node [shape=box, fontname="helvetica"] ;\n ' \
55
+ 'edge [fontname="helvetica"] ;\n ' \
54
56
'0 [label="feature0 <= 0.0\\ ngini = 0.5\\ nsamples = 6\\ n' \
55
57
'value = [3, 3]"] ;\n ' \
56
58
'1 [label="gini = 0.0\\ nsamples = 3\\ nvalue = [3, 0]"] ;\n ' \
@@ -66,7 +68,8 @@ def test_graphviz_toy():
66
68
# Test with class_names
67
69
contents1 = export_graphviz (clf , class_names = ["yes" , "no" ], out_file = None )
68
70
contents2 = 'digraph Tree {\n ' \
69
- 'node [shape=box] ;\n ' \
71
+ 'node [shape=box, fontname="helvetica"] ;\n ' \
72
+ 'edge [fontname="helvetica"] ;\n ' \
70
73
'0 [label="X[0] <= 0.0\\ ngini = 0.5\\ nsamples = 6\\ n' \
71
74
'value = [3, 3]\\ nclass = yes"] ;\n ' \
72
75
'1 [label="gini = 0.0\\ nsamples = 3\\ nvalue = [3, 0]\\ n' \
@@ -84,11 +87,11 @@ def test_graphviz_toy():
84
87
# Test plot_options
85
88
contents1 = export_graphviz (clf , filled = True , impurity = False ,
86
89
proportion = True , special_characters = True ,
87
- rounded = True , out_file = None )
90
+ rounded = True , out_file = None , fontname = "sans" )
88
91
contents2 = 'digraph Tree {\n ' \
89
92
'node [shape=box, style="filled, rounded", color="black", ' \
90
- 'fontname=helvetica ] ;\n ' \
91
- 'edge [fontname=helvetica ] ;\n ' \
93
+ 'fontname="sans" ] ;\n ' \
94
+ 'edge [fontname="sans" ] ;\n ' \
92
95
'0 [label=<X<SUB>0</SUB> ≤ 0.0<br/>samples = 100.0%<br/>' \
93
96
'value = [0.5, 0.5]>, fillcolor="#ffffff"] ;\n ' \
94
97
'1 [label=<samples = 50.0%<br/>value = [1.0, 0.0]>, ' \
@@ -107,7 +110,8 @@ def test_graphviz_toy():
107
110
contents1 = export_graphviz (clf , max_depth = 0 ,
108
111
class_names = True , out_file = None )
109
112
contents2 = 'digraph Tree {\n ' \
110
- 'node [shape=box] ;\n ' \
113
+ 'node [shape=box, fontname="helvetica"] ;\n ' \
114
+ 'edge [fontname="helvetica"] ;\n ' \
111
115
'0 [label="X[0] <= 0.0\\ ngini = 0.5\\ nsamples = 6\\ n' \
112
116
'value = [3, 3]\\ nclass = y[0]"] ;\n ' \
113
117
'1 [label="(...)"] ;\n ' \
@@ -122,7 +126,9 @@ def test_graphviz_toy():
122
126
contents1 = export_graphviz (clf , max_depth = 0 , filled = True ,
123
127
out_file = None , node_ids = True )
124
128
contents2 = 'digraph Tree {\n ' \
125
- 'node [shape=box, style="filled", color="black"] ;\n ' \
129
+ 'node [shape=box, style="filled", color="black", ' \
130
+ 'fontname="helvetica"] ;\n ' \
131
+ 'edge [fontname="helvetica"] ;\n ' \
126
132
'0 [label="node #0\\ nX[0] <= 0.0\\ ngini = 0.5\\ n' \
127
133
'samples = 6\\ nvalue = [3, 3]", fillcolor="#ffffff"] ;\n ' \
128
134
'1 [label="(...)", fillcolor="#C0C0C0"] ;\n ' \
@@ -143,7 +149,9 @@ def test_graphviz_toy():
143
149
contents1 = export_graphviz (clf , filled = True ,
144
150
impurity = False , out_file = None )
145
151
contents2 = 'digraph Tree {\n ' \
146
- 'node [shape=box, style="filled", color="black"] ;\n ' \
152
+ 'node [shape=box, style="filled", color="black", ' \
153
+ 'fontname="helvetica"] ;\n ' \
154
+ 'edge [fontname="helvetica"] ;\n ' \
147
155
'0 [label="X[0] <= 0.0\\ nsamples = 6\\ n' \
148
156
'value = [[3.0, 1.5, 0.0]\\ n' \
149
157
'[3.0, 1.0, 0.5]]", fillcolor="#ffffff"] ;\n ' \
@@ -174,12 +182,13 @@ def test_graphviz_toy():
174
182
clf .fit (X , y )
175
183
176
184
contents1 = export_graphviz (clf , filled = True , leaves_parallel = True ,
177
- out_file = None , rotate = True , rounded = True )
185
+ out_file = None , rotate = True , rounded = True ,
186
+ fontname = "sans" )
178
187
contents2 = 'digraph Tree {\n ' \
179
188
'node [shape=box, style="filled, rounded", color="black", ' \
180
- 'fontname=helvetica ] ;\n ' \
189
+ 'fontname="sans" ] ;\n ' \
181
190
'graph [ranksep=equally, splines=polyline] ;\n ' \
182
- 'edge [fontname=helvetica ] ;\n ' \
191
+ 'edge [fontname="sans" ] ;\n ' \
183
192
'rankdir=LR ;\n ' \
184
193
'0 [label="X[0] <= 0.0\\ nmse = 1.0\\ nsamples = 6\\ n' \
185
194
'value = 0.0", fillcolor="#f2c09c"] ;\n ' \
@@ -203,7 +212,9 @@ def test_graphviz_toy():
203
212
204
213
contents1 = export_graphviz (clf , filled = True , out_file = None )
205
214
contents2 = 'digraph Tree {\n ' \
206
- 'node [shape=box, style="filled", color="black"] ;\n ' \
215
+ 'node [shape=box, style="filled", color="black", ' \
216
+ 'fontname="helvetica"] ;\n ' \
217
+ 'edge [fontname="helvetica"] ;\n ' \
207
218
'0 [label="gini = 0.0\\ nsamples = 6\\ nvalue = 6.0", ' \
208
219
'fillcolor="#ffffff"] ;\n ' \
209
220
'}'
0 commit comments