Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jlwalke2 committed Feb 24, 2020
1 parent 608ff96 commit c951185
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/sasctl/utils/pyml2ds/connectors/ensembles/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,25 @@ def _aggregate(cls, booster_count):
return "treeValue = sum({});\n".format(', '.join(
"treeValue%d" % i for i in range(booster_count)))

def translate(self, f):
"""Translate a gradient boosting model and write SAS scoring code to a file.
def translate(self, file):
"""Translate a gradient boosting model and write SAS scoring code to
a file.
Attributes
----------
f : file object
file : file object
Open file for writing output SAS code.
"""
for booster_id, tree in self._iter_trees():
f.write("/* Parsing tree {}*/\n".format(booster_id))
file.write("/* Parsing tree {}*/\n".format(booster_id))

self._tree_parser.init(tree, booster_id)
self._tree_parser.parse_node(f)
f.write("\n")

f.write("/* Getting target probability */\n")
f.write(self._aggregate(booster_id + 1))
f.write("{} = {};\n".format(self.out_var_name,
self.out_transform.format("treeValue")))
self._tree_parser.parse_node(file)

file.write("\n")

file.write("/* Getting target probability */\n")
file.write(self._aggregate(booster_id + 1))
file.write("{} = {};\n".format(self.out_var_name,
self.out_transform.format("treeValue")))

0 comments on commit c951185

Please sign in to comment.