(self)
| 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 | |
| 143 | class Model: |
no test coverage detected