Fix monotone constraints on CPU. (#9122)

This commit is contained in:
Jiaming Yuan
2023-05-06 01:07:54 +08:00
committed by GitHub
parent 250b22dd22
commit 55968ed3fa
3 changed files with 37 additions and 0 deletions

View File

@@ -412,6 +412,7 @@ class HistEvaluator {
tree_evaluator_.AddSplit(candidate.nid, left_child, right_child,
tree[candidate.nid].SplitIndex(), left_weight,
right_weight);
evaluator = tree_evaluator_.GetEvaluator();
snode_.resize(tree.GetNodes().size());
snode_.at(left_child).stats = candidate.split.left_sum;

View File

@@ -49,6 +49,8 @@ class TreeEvaluator {
monotone_.HostVector().resize(n_features, 0);
has_constraint_ = false;
} else {
CHECK_LE(p.monotone_constraints.size(), n_features)
<< "The size of monotone constraint should be less or equal to the number of features.";
monotone_.HostVector() = p.monotone_constraints;
monotone_.HostVector().resize(n_features, 0);
// Initialised to some small size, can grow if needed