MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / Init

Method Init

src/io/ordered_sparse_bin.hpp:54–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 }
53
54 void Init(const char* used_idices, int num_leaves) override {
55 // initialize the leaf information
56 leaf_start_ = std::vector<data_size_t>(num_leaves, 0);
57 leaf_cnt_ = std::vector<data_size_t>(num_leaves, 0);
58 if (used_idices == nullptr) {
59 // if using all data, copy all non-zero pair
60 data_size_t j = 0;
61 data_size_t cur_pos = 0;
62 data_size_t i_delta = -1;
63 while (bin_data_->NextNonzero(&i_delta, &cur_pos)) {
64 ordered_pair_[j].ridx = cur_pos;
65 ordered_pair_[j].bin = bin_data_->vals_[i_delta];
66 ++j;
67 }
68 leaf_cnt_[0] = static_cast<data_size_t>(j);
69 } else {
70 // if using part of data(bagging)
71 data_size_t j = 0;
72 data_size_t cur_pos = 0;
73 data_size_t i_delta = -1;
74 while (bin_data_->NextNonzero(&i_delta, &cur_pos)) {
75 if (used_idices[cur_pos]) {
76 ordered_pair_[j].ridx = cur_pos;
77 ordered_pair_[j].bin = bin_data_->vals_[i_delta];
78 ++j;
79 }
80 }
81 leaf_cnt_[0] = j;
82 }
83 }
84
85 void ConstructHistogram(int leaf, const score_t* gradient, const score_t* hessian,
86 HistogramBinEntry* out) const override {

Callers

nothing calls this directly

Calls 1

NextNonzeroMethod · 0.45

Tested by

no test coverage detected