MCPcopy Create free account
hub / github.com/dmlc/xgboost / __str__

Method __str__

demo/guide-python/model_parser.py:112–140  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

110 return self.split_index(node_id) == np.iinfo(np.uint32).max
111
112 def __str__(self) -> str:
113 stack = [0]
114 nodes = []
115 while stack:
116 node: Dict[str, Union[float, int, List[int]]] = {}
117 nid = stack.pop()
118
119 node["node id"] = nid
120 node["gain"] = self.loss_change(nid)
121 node["cover"] = self.sum_hessian(nid)
122 nodes.append(node)
123
124 if not self.is_leaf(nid) and not self.is_deleted(nid):
125 left = self.left_child(nid)
126 right = self.right_child(nid)
127 stack.append(left)
128 stack.append(right)
129 categories = self.split_categories(nid)
130 if categories:
131 assert self.is_categorical(nid)
132 node["categories"] = categories
133 else:
134 assert self.is_numerical(nid)
135 node["condition"] = self.split_condition(nid)
136 if self.is_leaf(nid):
137 node["weight"] = self.split_condition(nid)
138
139 string = "\n".join(map(lambda x: " " + str(x), nodes))
140 return string
141
142
143class Model:

Callers 2

executeMethod · 0.80
executeMethod · 0.80

Calls 10

loss_changeMethod · 0.95
sum_hessianMethod · 0.95
is_leafMethod · 0.95
is_deletedMethod · 0.95
left_childMethod · 0.95
right_childMethod · 0.95
split_categoriesMethod · 0.95
is_categoricalMethod · 0.95
is_numericalMethod · 0.95
split_conditionMethod · 0.95

Tested by

no test coverage detected