Test if v is contained within the range i and j
Calculate the constraint weight given bounds
and a constraint.
Cull gain, if it does not conform to constraints.
Fast summation, but using f64 as the internal representation so that
we don’t have issues with the precision.
This way, we can still work with f32 values, but get the correct sum
value.
Fast summation, ends up being roughly 8 to 10 times faster
than values.iter().copied().sum().
Shamelessly stolen from https://stackoverflow.com/a/67191480
Calculate the gain given the gradient and hessian of the node.
Calculate the gain of a split given a specific weight value.
This is for if the weight has to be constrained, for example for
monotonicity constraints.
Calculate if a value is missing.
Create a string of all available items.
Calculate l1 regularization
Return the index of the first value in a sorted
vector that is greater than a provided value.
Function to compare a value to our split value.
Our split value will never be missing (0), thus we
don’t have to worry about that.
Convert Log odds to probability
Naive weighted percentiles calculation.
Provided a list of index values, pivot those values
around a specific split value so all of the values less
than the split value are on one side, and then all of the
values greater than or equal to the split value are above.
Provided a list of index values, pivot those values
around a specific split value so all of the values less
than the split value are on one side, and then all of the
values greater than or equal to the split value are above.
Missing values, will be pushed to the bottom, a value of
zero is missing in this case.
Returns a tuple, the first is the first non-missing value
index, the second is the first value that is greater than
our provided split value.
Calculate the weight of a given node, given the sum
of the gradients, and the hessians in a node.