I would like to know that how xgboost enforce monotonic constraints while building the tree model. So far by reading the code, I have understood that it has something to do with weights of each node but am not able to understand why this approach works. Thanks in advance for your answers
Asked
Active
Viewed 1,874 times
1 Answers
2
Here is a simple pseudocode for the same feature in LightGBM:
min_value = node.min_value
max_value = node.max_value
check(min_value <= split.left_output)
check(min_value <= split.right_output)
check(max_value >= split.left_otput)
check(max_value >= split.right_output)
mid = (split.left_output + split.right_output) / 2;
if (split.feature is monotonic increasing) {
check(split.left_output <= split.right_output)
node.left_child.set_max_value(mid)
node.right_child.set_min_value(mid)
}
if (split.feature is monotonic decreasing ) {
check(split.left_output >= split.right_output)
node.left_child.set_min_value(mid)
node.right_child.set_max_value(mid)
}
Reference: https://github.com/Microsoft/LightGBM/issues/14#issuecomment-359752223.
I believe it's basically the same algorithm as the one implemented in XGBoost.
For each split candidate:
- Check the values of both leaves against the monotonicity constraints propagated from predecessors.
- Check the monotonicity between two leaves.
- Reject the split if the monotonicity is broken.

NightOwl888
- 55,572
- 24
- 139
- 212

fedyakov
- 63
- 9
-
it would be helpful to readers if you can define/describe the variables – dksahuji Jun 28 '18 at 08:35
-
also can you comment on multiclass problem with monotone constraint – dksahuji Jun 29 '18 at 09:44