46   virtual char const* 
what() const noexcept { 
return msg_; }
 
   55 template <
typename decision_forest_t>
 
   58   using node_type = 
typename decision_forest_t::node_type;
 
   61   template <
typename iter_t>
 
   65     std::optional<int> tl_node_id                     = std::nullopt,
 
   66     std::size_t depth                                 = std::size_t{1},
 
   67     bool default_to_distant_child                     = 
false,
 
   68     typename node_type::metadata_storage_type feature = 
typename node_type::metadata_storage_type{},
 
   69     typename node_type::offset_type offset            = 
typename node_type::offset_type{})
 
   73     auto set_storage               = &node_value;
 
   74     auto max_node_categories =
 
   75       (vec_begin != vec_end) ? *std::max_element(vec_begin, vec_end) + 1 : 1;
 
   76     if (max_num_categories_ > bin_width) {
 
   78       node_value         = categorical_storage_.size();
 
   80       categorical_storage_.push_back(max_node_categories);
 
   81       categorical_storage_.resize(categorical_storage_.size() + bins_required);
 
   82       set_storage = &(categorical_storage_[node_value + 1]);
 
   84     auto set = bitset{set_storage, max_node_categories};
 
   85     std::for_each(vec_begin, vec_end, [&set](
auto&& cat_index) { set.set(cat_index); });
 
   88       node_value, tl_node_id, depth, 
false, default_to_distant_child, 
true, feature, offset, 
false);
 
   92   template <
typename iter_t>
 
   95                             std::optional<int> tl_node_id = std::nullopt,
 
   96                             std::size_t depth             = std::size_t{1})
 
   99     std::copy(vec_begin, vec_end, std::back_inserter(vector_output_));
 
  107              typename node_type::metadata_storage_type{},
 
  108              typename node_type::offset_type{},
 
  113   template <
typename value_t>
 
  116     std::optional<int> tl_node_id                     = std::nullopt,
 
  117     std::size_t depth                                 = std::size_t{1},
 
  118     bool is_leaf_node                                 = 
true,
 
  119     bool default_to_distant_child                     = 
false,
 
  120     bool is_categorical_node                          = 
false,
 
  121     typename node_type::metadata_storage_type feature = 
typename node_type::metadata_storage_type{},
 
  122     typename node_type::offset_type offset            = 
typename node_type::offset_type{},
 
  123     bool is_inclusive                                 = 
false)
 
  125     if (depth == std::size_t{}) {
 
  127         if (cur_node_index_ % alignment_ != 
index_type{}) {
 
  128           auto padding = (alignment_ - cur_node_index_ % alignment_);
 
  129           for (
auto i = 
index_type{}; i < padding; ++i) {
 
  130             add_node(
typename node_type::threshold_type{}, std::nullopt);
 
  134       root_node_indexes_.push_back(cur_node_index_);
 
  137     if (is_inclusive) { val = std::nextafter(val, std::numeric_limits<value_t>::infinity()); }
 
  139       val, is_leaf_node, default_to_distant_child, is_categorical_node, feature, offset);
 
  141     node_id_mapping_.push_back(
static_cast<index_type>(tl_node_id.value_or(0)));
 
  159     if (output_size_ != 
index_type{1} && output_size_ != val) {
 
  168       max_num_categories_{max_num_categories},
 
  175       postproc_constant_{},
 
  177       root_node_indexes_{},
 
  192 #pragma GCC diagnostic push 
  193 #pragma GCC diagnostic ignored "-Wnarrowing" 
  194     return decision_forest_t{
 
  207       max_num_categories_ != 0,
 
  208       vector_output_.empty()
 
  210         : std::make_optional<raft_proto::buffer<typename node_type::threshold_type>>(
 
  215       categorical_storage_.empty()
 
  217         : std::make_optional<raft_proto::buffer<typename node_type::index_type>>(
 
  225       static_cast<typename node_type::threshold_type
>(average_factor_),
 
  226       static_cast<typename node_type::threshold_type
>(bias_),
 
  227       static_cast<typename node_type::threshold_type
>(postproc_constant_)};
 
  228 #pragma GCC diagnostic pop 
  238   double average_factor_;
 
  240   double postproc_constant_;
 
  242   std::vector<node_type> nodes_;
 
  243   std::vector<index_type> root_node_indexes_;
 
  244   std::vector<typename node_type::threshold_type> vector_output_;
 
  245   std::vector<typename node_type::index_type> categorical_storage_;
 
  246   std::vector<index_type> node_id_mapping_;
 
row_op
Definition: postproc_ops.hpp:21
 
element_op
Definition: postproc_ops.hpp:28
 
uint32_t index_type
Definition: index_type.hpp:20
 
Definition: dbscan.hpp:29
 
HOST DEVICE constexpr auto ceildiv(T dividend, U divisor)
Definition: ceildiv.hpp:21
 
int cuda_stream
Definition: cuda_stream.hpp:25
 
device_type
Definition: device_type.hpp:18
 
const_agnostic_same_t< T, U > copy(buffer< T > &dst, buffer< U > const &src, typename buffer< T >::index_type dst_offset, typename buffer< U >::index_type src_offset, typename buffer< T >::index_type size, cuda_stream stream)
Definition: buffer.hpp:327
 
Definition: decision_forest_builder.hpp:56
 
void set_average_factor(double val)
Definition: decision_forest_builder.hpp:150
 
void set_bias(double val)
Definition: decision_forest_builder.hpp:152
 
void set_postproc_constant(double val)
Definition: decision_forest_builder.hpp:155
 
decision_forest_builder(index_type max_num_categories=index_type{}, index_type align_bytes=index_type{})
Definition: decision_forest_builder.hpp:165
 
void set_row_postproc(row_op val)
Definition: decision_forest_builder.hpp:148
 
void add_node(value_t val, std::optional< int > tl_node_id=std::nullopt, std::size_t depth=std::size_t{1}, bool is_leaf_node=true, bool default_to_distant_child=false, bool is_categorical_node=false, typename node_type::metadata_storage_type feature=typename node_type::metadata_storage_type{}, typename node_type::offset_type offset=typename node_type::offset_type{}, bool is_inclusive=false)
Definition: decision_forest_builder.hpp:114
 
void add_categorical_node(iter_t vec_begin, iter_t vec_end, std::optional< int > tl_node_id=std::nullopt, std::size_t depth=std::size_t{1}, bool default_to_distant_child=false, typename node_type::metadata_storage_type feature=typename node_type::metadata_storage_type{}, typename node_type::offset_type offset=typename node_type::offset_type{})
Definition: decision_forest_builder.hpp:62
 
void set_output_size(index_type val)
Definition: decision_forest_builder.hpp:157
 
auto get_decision_forest(index_type num_feature, index_type num_class, raft_proto::device_type mem_type=raft_proto::device_type::cpu, int device=0, raft_proto::cuda_stream stream=raft_proto::cuda_stream{})
Definition: decision_forest_builder.hpp:183
 
void set_element_postproc(element_op val)
Definition: decision_forest_builder.hpp:146
 
void add_leaf_vector_node(iter_t vec_begin, iter_t vec_end, std::optional< int > tl_node_id=std::nullopt, std::size_t depth=std::size_t{1})
Definition: decision_forest_builder.hpp:93
 
typename decision_forest_t::node_type node_type
Definition: decision_forest_builder.hpp:58
 
Definition: decision_forest_builder.hpp:43
 
model_builder_error(char const *msg)
Definition: decision_forest_builder.hpp:45
 
virtual char const  * what() const noexcept
Definition: decision_forest_builder.hpp:46
 
model_builder_error()
Definition: decision_forest_builder.hpp:44
 
Definition: exceptions.hpp:35
 
A container which may or may not own its own data on host or device.
Definition: buffer.hpp:41