| 207 | #undef PredictionFun |
| 208 | |
| 209 | std::string Tree::ToString() const { |
| 210 | std::stringstream str_buf; |
| 211 | str_buf << "num_leaves=" << num_leaves_ << '\n'; |
| 212 | str_buf << "num_cat=" << num_cat_ << '\n'; |
| 213 | str_buf << "split_feature=" |
| 214 | << Common::ArrayToStringFast(split_feature_, num_leaves_ - 1) << '\n'; |
| 215 | str_buf << "split_gain=" |
| 216 | << Common::ArrayToStringFast(split_gain_, num_leaves_ - 1) << '\n'; |
| 217 | str_buf << "threshold=" |
| 218 | << Common::ArrayToString(threshold_, num_leaves_ - 1) << '\n'; |
| 219 | str_buf << "decision_type=" |
| 220 | << Common::ArrayToStringFast(Common::ArrayCast<int8_t, int>(decision_type_), num_leaves_ - 1) << '\n'; |
| 221 | str_buf << "left_child=" |
| 222 | << Common::ArrayToStringFast(left_child_, num_leaves_ - 1) << '\n'; |
| 223 | str_buf << "right_child=" |
| 224 | << Common::ArrayToStringFast(right_child_, num_leaves_ - 1) << '\n'; |
| 225 | str_buf << "leaf_value=" |
| 226 | << Common::ArrayToString(leaf_value_, num_leaves_) << '\n'; |
| 227 | str_buf << "leaf_weight=" |
| 228 | << Common::ArrayToString(leaf_weight_, num_leaves_) << '\n'; |
| 229 | str_buf << "leaf_count=" |
| 230 | << Common::ArrayToStringFast(leaf_count_, num_leaves_) << '\n'; |
| 231 | str_buf << "internal_value=" |
| 232 | << Common::ArrayToStringFast(internal_value_, num_leaves_ - 1) << '\n'; |
| 233 | str_buf << "internal_weight=" |
| 234 | << Common::ArrayToStringFast(internal_weight_, num_leaves_ - 1) << '\n'; |
| 235 | str_buf << "internal_count=" |
| 236 | << Common::ArrayToStringFast(internal_count_, num_leaves_ - 1) << '\n'; |
| 237 | if (num_cat_ > 0) { |
| 238 | str_buf << "cat_boundaries=" |
| 239 | << Common::ArrayToStringFast(cat_boundaries_, num_cat_ + 1) << '\n'; |
| 240 | str_buf << "cat_threshold=" |
| 241 | << Common::ArrayToStringFast(cat_threshold_, cat_threshold_.size()) << '\n'; |
| 242 | } |
| 243 | str_buf << "shrinkage=" << shrinkage_ << '\n'; |
| 244 | str_buf << '\n'; |
| 245 | return str_buf.str(); |
| 246 | } |
| 247 | |
| 248 | std::string Tree::ToJSON() const { |
| 249 | std::stringstream str_buf; |
no test coverage detected