# Math behind XGBRegressor.predict

Hi,

I’m struggling to understand how the prediction of a XGBRegressor is computed using its parameters like base_weights, split_conditions etc., but find it quite tough to follow the code in GitHub.

I think I understand how a single tree is constructed using ‘left_children’, ‘right_children’, ‘parents’ and ‘split_indices’ (and possibly ‘split_type’, assuming that split_type=0 meaning the check if the input value is < than the ‘split_condition’ (?)).

I trained a simple model using one tree with only one split to understand whats going on. The training resulted in the following parameters.

Tree-parameters
‘base_weights’: [-0.5072559, -0.60650694, -0.34721765]
‘split_conditions’: [0.0602537, -0.18195209, -0.1041653]

Possibly important parameters
‘base_score’: 0.5
‘default_left’: [1, 0, 0]
‘loss_changes’: [1.3936901, 0.0, 0.0]
‘sum_hessian’: [100.0, 60.0, 40.0]

For an input value of 0,0725 a predicted value of 0,39583 is computed.

Can somebody please explain how to compute the predicted output using the given parameters? The general Idea for even more complex models would be great as well. Thanks!

Kind regards

I forgot to mention the tree’s structure even though I think that such a simple tree is constructed the same anytime.

‘left_children’: [1, -1, -1]
‘right_children’: [1, -1, -1]
‘parents’: [seemingly a random Number (perhaps an address), 0, 0]
‘split_indices’: [0, 0, 0]