6#ifndef XGBOOST_MULTI_TARGET_TREE_MODEL_H_
7#define XGBOOST_MULTI_TARGET_TREE_MODEL_H_
12#include <xgboost/span.h>
25 static bst_node_t constexpr InvalidNodeId() {
return -1; }
29 std::vector<bst_node_t> left_;
30 std::vector<bst_node_t> right_;
31 std::vector<bst_node_t> parent_;
32 std::vector<bst_feature_t> split_index_;
33 std::vector<std::uint8_t> default_left_;
34 std::vector<float> split_conds_;
35 std::vector<float> weights_;
38 auto beg = nidx * this->NumTarget();
43 auto beg = nidx * this->NumTarget();
62 [[nodiscard]]
bool IsLeaf(
bst_node_t nidx)
const {
return left_[nidx] == InvalidNodeId(); }
68 [[nodiscard]]
float SplitCond(
bst_node_t nidx)
const {
return split_conds_[nidx]; }
69 [[nodiscard]]
bool DefaultLeft(
bst_node_t nidx)
const {
return default_left_[nidx]; }
71 return this->DefaultLeft(nidx) ? this->LeftChild(nidx) : this->RightChild(nidx);
76 [[nodiscard]] std::size_t Size()
const;
80 while (Parent(nidx) != InvalidNodeId()) {
89 return this->NodeWeight(nidx);
Data structure representing JSON format.
Definition json.h:357
Tree structure for multi-target model.
Definition multi_target_tree_model.h:23
void SaveModel(Json *out) const override
saves the model config to a JSON object
Definition multi_target_tree_model.cc:98
void SetLeaf(bst_node_t nidx, linalg::VectorView< float const > weight)
Set the weight for a leaf.
Definition multi_target_tree_model.cc:156
void Expand(bst_node_t nidx, bst_feature_t split_idx, float split_cond, bool default_left, linalg::VectorView< float const > base_weight, linalg::VectorView< float const > left_weight, linalg::VectorView< float const > right_weight)
Expand a leaf into split node.
Definition multi_target_tree_model.cc:167
void LoadModel(Json const &in) override
load the model from a JSON object
Definition multi_target_tree_model.cc:78
span class implementation, based on ISO++20 span<T>. The interface should be the same.
Definition span.h:424
XGBOOST_DEVICE auto subspan() const -> Span< element_type, detail::ExtentValue< Extent, Offset, Count >::value >
Definition span.h:596
A tensor view with static type and dimension.
Definition linalg.h:293
Copyright 2014-2023, XGBoost Contributors.
Copyright 2015-2023 by XGBoost Contributors.
Copyright 2021-2023 by XGBoost Contributors.
Defines the abstract interface for different components in XGBoost.
auto MakeTensorView(Context const *ctx, Container &data, S &&...shape)
Constructor for automatic type deduction.
Definition linalg.h:576
namespace of xgboost
Definition base.h:90
uint32_t bst_feature_t
Type for data column (feature) index.
Definition base.h:101
std::int32_t bst_node_t
Type for tree node index.
Definition base.h:112
std::uint32_t bst_target_t
Type for indexing into output targets.
Definition base.h:118
meta parameters of the tree
Definition tree_model.h:35