Skip to content

Commit f97eb61

Browse files
committed
Corrected json for regressioh decision trees
1 parent 9ac920a commit f97eb61

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

converters/decison_tree_converter.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get_tree_as_dict(self, clf):
2424
lDict1 = clf.__dict__
2525
lDict["features"] = lDict1['n_features_in_']
2626
lDict["outputs"] = lDict1['n_outputs_']
27-
lDict["max_depth"] = lDict1['max_depth']
27+
lDict["max_depth"] = tree.max_depth
2828
node_count = len(tree.n_node_samples)
2929
lDict["node_count"] = node_count
3030
nodes = {}
@@ -33,7 +33,8 @@ def get_tree_as_dict(self, clf):
3333
node_id_str = ('0'*P + str(node_id))[-P:]
3434
# print("NODE_ID_STR ", P, node_id, node_id_str)
3535
normalized_value = tree.value[node_id][0]
36-
normalized_value = normalized_value / np.sum(normalized_value)
36+
if(normalized_value.shape[0] > 1):
37+
normalized_value = normalized_value / np.sum(normalized_value)
3738
nodes["node_" + node_id_str ] = {
3839
"left" : tree.children_left[node_id],
3940
"right" : tree.children_right[node_id],

0 commit comments

Comments
 (0)