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

Extract interaction constraint from split evaluator. #5034

Merged
merged 22 commits into from
Nov 14, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restore some changes.
  • Loading branch information
trivialfis committed Nov 13, 2019
commit a465bf1043eab91cbcc21b361ca8f075e1c11931
14 changes: 9 additions & 5 deletions src/tree/updater_histmaker.cc
Original file line number Diff line number Diff line change
@@ -208,9 +208,9 @@ class HistMaker: public BaseMaker {
void FindSplit(int depth,
const std::vector<GradientPair> &gpair,
DMatrix *p_fmat,
const std::vector <bst_feature_t> &selected_features_,
const std::vector <bst_feature_t> &feature_set,
RegTree *p_tree) {
const size_t num_feature = selected_features_.size();
const size_t num_feature = feature_set.size();
// get the best split condition for each node
std::vector<SplitEntry> sol(qexpand_.size());
std::vector<GradStats> left_sum(qexpand_.size());
@@ -221,14 +221,14 @@ class HistMaker: public BaseMaker {
CHECK_EQ(node2workindex_[nid], static_cast<int>(wid));
SplitEntry &best = sol[wid];
GradStats &node_sum = wspace_.hset[0][num_feature + wid * (num_feature + 1)].data[0];
for (size_t i = 0; i < selected_features_.size(); ++i) {
for (size_t i = 0; i < feature_set.size(); ++i) {
// Query is thread safe as it's a const function.
if (!this->interaction_constraints_.Query(nid, selected_features_[i])) {
if (!this->interaction_constraints_.Query(nid, feature_set[i])) {
continue;
}

EnumerateSplit(this->wspace_.hset[0][i + wid * (num_feature+1)],
node_sum, selected_features_[i], &best, &left_sum[wid]);
node_sum, feature_set[i], &best, &left_sum[wid]);
}
}
// get the best result, we can synchronize the solution
@@ -253,8 +253,12 @@ class HistMaker: public BaseMaker {
best.DefaultLeft(), base_weight, left_leaf_weight,
right_leaf_weight, best.loss_chg,
node_sum.sum_hess);
GradStats right_sum;
right_sum.SetSubstract(node_sum, left_sum[wid]);
auto left_child = (*p_tree)[nid].LeftChild();
auto right_child = (*p_tree)[nid].RightChild();
this->SetStats(p_tree, left_child, left_sum[wid]);
this->SetStats(p_tree, right_child, right_sum);
this->interaction_constraints_.Split(nid, best.SplitIndex(), left_child, right_child);
} else {
(*p_tree)[nid].SetLeaf(p_tree->Stat(nid).base_weight * param_.learning_rate);