Require leaf statistics when expanding tree (#4015)

* Cache left and right gradient sums

* Require leaf statistics when expanding tree
This commit is contained in:
Rory Mitchell
2019-01-18 07:12:20 +02:00
committed by Philip Hyunsu Cho
parent 0f8af85f64
commit 1fc37e4749
11 changed files with 143 additions and 85 deletions

View File

@@ -38,22 +38,13 @@ TEST(Updater, Prune) {
pruner->Init(cfg);
// loss_chg < min_split_loss;
tree.ExpandNode(0, 0, 0, true);
int cleft = tree[0].LeftChild();
int cright = tree[0].RightChild();
tree[cleft].SetLeaf(0.3f, 0);
tree[cright].SetLeaf(0.4f, 0);
tree.ExpandNode(0, 0, 0, true, 0.0f, 0.3f, 0.4f, 0.0f, 0.0f);
pruner->Update(&gpair, dmat->get(), trees);
ASSERT_EQ(tree.NumExtraNodes(), 0);
// loss_chg > min_split_loss;
tree.ExpandNode(0, 0, 0, true);
cleft = tree[0].LeftChild();
cright = tree[0].RightChild();
tree[cleft].SetLeaf(0.3f, 0);
tree[cright].SetLeaf(0.4f, 0);
tree.Stat(0).loss_chg = 11;
tree.ExpandNode(0, 0, 0, true, 0.0f, 0.3f, 0.4f, 11.0f, 0.0f);
pruner->Update(&gpair, dmat->get(), trees);
ASSERT_EQ(tree.NumExtraNodes(), 2);