| 106 | } |
| 107 | |
| 108 | void GrowTree(RegTree* p_tree) { |
| 109 | SimpleLCG lcg; |
| 110 | size_t n_expands = 10; |
| 111 | constexpr size_t kCols = 256; |
| 112 | SimpleRealUniformDistribution<double> coin(0.0, 1.0); |
| 113 | SimpleRealUniformDistribution<double> feat(0.0, kCols); |
| 114 | SimpleRealUniformDistribution<double> split_cat(0.0, 128.0); |
| 115 | SimpleRealUniformDistribution<double> split_value(0.0, kCols); |
| 116 | |
| 117 | std::stack<bst_node_t> stack; |
| 118 | stack.push(RegTree::kRoot); |
| 119 | auto& tree = *p_tree; |
| 120 | |
| 121 | for (size_t i = 0; i < n_expands; ++i) { |
| 122 | auto is_cat = coin(&lcg) <= 0.5; |
| 123 | bst_node_t node = stack.top(); |
| 124 | stack.pop(); |
| 125 | |
| 126 | bst_feature_t f = feat(&lcg); |
| 127 | if (is_cat) { |
| 128 | bst_cat_t cat = common::AsCat(split_cat(&lcg)); |
| 129 | std::vector<uint32_t> split_cats( |
| 130 | LBitField32::ComputeStorageSize(cat + 1)); |
| 131 | LBitField32 bitset{split_cats}; |
| 132 | bitset.Set(cat); |
| 133 | tree.ExpandCategorical(node, f, split_cats, true, 1.0, 2.0, 3.0, 11.0, 2.0, |
| 134 | /*left_sum=*/3.0, /*right_sum=*/4.0); |
| 135 | } else { |
| 136 | auto split = split_value(&lcg); |
| 137 | tree.ExpandNode(node, f, split, true, 1.0, 2.0, 3.0, 11.0, 2.0, |
| 138 | /*left_sum=*/3.0, /*right_sum=*/4.0); |
| 139 | } |
| 140 | |
| 141 | stack.push(tree[node].LeftChild()); |
| 142 | stack.push(tree[node].RightChild()); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | void CheckReload(RegTree const &tree) { |
| 147 | Json out{Object()}; |
no test coverage detected