2
$\begingroup$

I am trying to get direct connection between Gain and Logloss for XGBoost. It looks to me that in Xgboost paper formula 6:

enter image description here

for a model with depth 1 and number of trees=1 this formula contains Similarity score for the node. On the other hand formula 6 approximates minimum loss and should be equal to logloss value of the model.

However when I calculate by hands at google spreadsheet these two values are different. Please have a look at:

  1. sheet "One tree depth2"
  2. Logloss in Cell K47=0,30 (which matches python code below)
  3. Similarity score for the node Cell O47=0,05 - these values doesn't match.

Code to train model which return values mentioned above (you have to download input data from google spreadsheet at sheet "raw_data":

df = pd.read_excel('Xgboost calculation.xlsx', sheet_name='raw_data')
x=df[[0,1]].values
y=df['TARGET'].values
model = xgb.XGBClassifier(verbosity = 0,n_estimators=1,max_depth=1,learning_rate=1,reg_alpha=0,reg_lambda=0,subsample=1,
                          min_child_weight=0)
model.fit(x, y,eval_set=[(x, y)])

My question is why doesnt Logloss match Similarity score in this example? Is it due to taylor's approximation?

$\endgroup$
5
  • 1
    $\begingroup$ Please edit your title and post to contain a question. As it stands, it's hard to know exactly what you want to know. $\endgroup$
    – Sycorax
    Commented Jan 30, 2023 at 13:34
  • $\begingroup$ Thanks for editing to include a question. This is very helpful. But it looks like some of the hyperlinks were broken when you made the last edit. $\endgroup$
    – Sycorax
    Commented Jan 30, 2023 at 14:16
  • $\begingroup$ +1 as this question clearly is showing research effort but... right now it seems you are asking some stranger to: 1. do some data loading from a spreadsheet on the Internet, 2. code a tiny modelling script up, 3. extract the intermediate/diagnostic values, 4. validate those values against your raw results stored in a different sheet, 5. validate then the calculations you have on this new sheet are correct, and then 6. explain why something happens (assuming they know what is going on). You have a higher opinion about strangers on the Internet than me... Google "min reproducible example SO". :) $\endgroup$
    – usεr11852
    Commented Jan 30, 2023 at 14:19
  • 2
    $\begingroup$ Actually I thought that formula would be sufficient. Anyway If i find the answer I will post it here. $\endgroup$
    – FedorT54
    Commented Jan 30, 2023 at 14:25
  • 1
    $\begingroup$ Please do! I will happily upvote that too! $\endgroup$
    – usεr11852
    Commented Jan 30, 2023 at 14:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.