Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix updates in random forest model using GOSS data sample strategy #6017

Merged
merged 11 commits into from
Sep 5, 2023
1 change: 0 additions & 1 deletion include/LightGBM/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ struct Config {
// descl2 = **Note**: internally, LightGBM uses ``gbdt`` mode for the first ``1 / learning_rate`` iterations
std::string boosting = "gbdt";

// [doc-only]
// type = enum
// options = bagging, goss
// desc = ``bagging``, Randomly Bagging Sampling
Expand Down
6 changes: 6 additions & 0 deletions src/boosting/rf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ class RF : public GBDT {
const data_size_t bag_data_cnt = data_sample_strategy_->bag_data_cnt();
const std::vector<data_size_t, Common::AlignmentAllocator<data_size_t, kAlignedSize>>& bag_data_indices = data_sample_strategy_->bag_data_indices();

// GOSSStrategy->Bagging may modify value of bag_data_cnt_
if (is_use_subset && bag_data_cnt < num_data_) {
tmp_grad_.resize(num_data_);
tmp_hess_.resize(num_data_);
}

CHECK_EQ(gradients, nullptr);
CHECK_EQ(hessians, nullptr);

Expand Down
1 change: 1 addition & 0 deletions src/io/config_auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ std::string Config::SaveMembersToString() const {
str_buf << "[max_depth: " << max_depth << "]\n";
str_buf << "[min_data_in_leaf: " << min_data_in_leaf << "]\n";
str_buf << "[min_sum_hessian_in_leaf: " << min_sum_hessian_in_leaf << "]\n";
str_buf << "[data_sample_strategy: " << data_sample_strategy << "]\n";
jameslamb marked this conversation as resolved.
Show resolved Hide resolved
str_buf << "[bagging_fraction: " << bagging_fraction << "]\n";
str_buf << "[pos_bagging_fraction: " << pos_bagging_fraction << "]\n";
str_buf << "[neg_bagging_fraction: " << neg_bagging_fraction << "]\n";
Expand Down