! * \brief Init, will put all data on the root(leaf_idx = 0) */
| 57 | * \brief Init, will put all data on the root(leaf_idx = 0) |
| 58 | */ |
| 59 | void Init() { |
| 60 | std::fill(leaf_begin_.begin(), leaf_begin_.end(), 0); |
| 61 | std::fill(leaf_count_.begin(), leaf_count_.end(), 0); |
| 62 | if (used_data_indices_ == nullptr) { |
| 63 | // if using all data |
| 64 | leaf_count_[0] = num_data_; |
| 65 | #pragma omp parallel for schedule(static) |
| 66 | for (data_size_t i = 0; i < num_data_; ++i) { |
| 67 | indices_[i] = i; |
| 68 | } |
| 69 | } else { |
| 70 | // if bagging |
| 71 | leaf_count_[0] = used_data_count_; |
| 72 | std::memcpy(indices_.data(), used_data_indices_, used_data_count_ * sizeof(data_size_t)); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | void ResetByLeafPred(const std::vector<int>& leaf_pred, int num_leaves) { |
| 77 | ResetLeaves(num_leaves); |