Require leaf statistics when expanding tree (#4015)
* Cache left and right gradient sums * Require leaf statistics when expanding tree
This commit is contained in:
committed by
Philip Hyunsu Cho
parent
0f8af85f64
commit
1fc37e4749
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user