XGBoost. How to get class probabilities from xgb.dump (multi: softprob target)

I have a 3 class classification using XGBoost. The next turn is to get the tree model (printed by xgb.dump ()) and use it in the .net production system. I really don't understand how I can get a 3-dimensional probability value from a single value on vacation:

<code>
[1107] "booster[148]""0:[f24<1.5] yes=1,no=2,missing=1"          
[1109] "1:[f4<0.085] yes=3,no=4,missing=3""3:leaf=0.00624765"                         
[1111] "4:leaf=-0.0208106""2:[f4<0.115] yes=5,no=6,missing=5"         
[1113] "5:leaf=0.14725""6:leaf=0.0102657"  
</code>

ps .Net python usinng function from .Net is not a good idea due to speed limits.

+1
source share
1 answer

It took some time to understand. After you receive your tree, follow these steps:

  • . 0, - 1, - 2, 0 1 .. , 10 num_round, 30 .

    "". DMatrix, xgb 0 . , , node x, = x, <0. - , DMatrix . , , , NA, () , . , 0 , . , 1 0 , node ..

  • , 3 . , l1_0,l2_0,l3_0 0 - l1_1,l2_1,l3_1 1 l1_2,l2_2,l3_2 2.

    , , , - output_margin pred_leaf. . pred_leaf, , , , . output_margin, , xgb.

    0.5 + l1_0+l2_0+l3_0 0 .. , output_margin. 0.5 - .

  • , v0, v1 v2 + . 0

       p(class0) = exp(v0)/(exp(v0)+exp(v1)+exp(v2))
    
+3

Source: https://habr.com/ru/post/1607493/


All Articles