dmlc / XGBoost.jl

XGBoost Julia Package
Other
288 stars 110 forks source link

trees() function with objective multi:softprob #149

Closed bobaronoff closed 1 year ago

bobaronoff commented 1 year ago

The trees() function returns a vector of model trees. The objective multi:softprob returns 'num_class' separate models. Therefore the tree() function returns a one dimensional vector of length (num_round*num_class). I am happy to reshape this tree vector but could use guidance as to whether the trees are are listed 'by column, or 'by row' order. (There was a somewhat similar issue with predictions and multi:softprob; turns out those were 'row order'.)

Thank you for your help.

bobaronoff commented 1 year ago

reshaping the trees vector by row order (as opposed to column order) seems to look correct. It is interesting that the R package does not reshape this vector - makes me think not too many utilize this function. Do not think any modification needed for xgboost.jl . However, some info regarding reshape in the docstring might save someone else some time.

As an aside, the gamma parameter is very helpful in adding bias and reducing overfit. If one plots number of splits per tree vs. iteration number it becomes obvious how effective gamma is in reducing model complexity while improving generalization.

ExpandingMan commented 1 year ago

Yes, I agree that this should automatically be reshaped if this is indeed how the trees are generated.

I'm not sure what the best way to do this is, the booster object doesn't store this information directly. I think in the worst case scenario we can take it from the parameters dict that we store with the Julia booster wrapper object.

bobaronoff commented 1 year ago

It may be best to leave things as they are. As far as I can tell this only affects multi:softprob and (based on lack of any google discussions) very few show an interest in looking at trees. It is easy enough for the end user to reshape. My vote would be to simply provide instructions in the docstring. If there are others that clammer could re-think and recode.