From 9f3532f15ee3cb70ca30e8916d9da3d5c891d860 Mon Sep 17 00:00:00 2001 From: jinlow Date: Tue, 19 Sep 2023 15:44:51 -0500 Subject: [PATCH] Set missing node to parent, if there are no missing records --- src/splitter.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/splitter.rs b/src/splitter.rs index 646fce9..dff58b9 100644 --- a/src/splitter.rs +++ b/src/splitter.rs @@ -396,14 +396,22 @@ impl Splitter for MissingBranchSplitter { (right_weight * right_hessian + left_weight * left_hessian) / (right_hessian + left_hessian) } - MissingNodeTreatment::None => constrained_weight( - &self.get_l2(), - missing_gradient, - missing_hessian, - lower_bound, - upper_bound, - constraint, - ), + MissingNodeTreatment::None => { + // If there are no missing records, just default + // to the parent weight. + if missing_hessian == 0. || missing_gradient == 0. { + parent_weight + } else { + constrained_weight( + &self.get_l2(), + missing_gradient, + missing_hessian, + lower_bound, + upper_bound, + constraint, + ) + } + } }; let missing_gain = gain_given_weight( &self.get_l2(),