Why doesn't xgboost create my trees?

I run the xgboost model as follows:

bst <- xgb.train(data=dtrain, booster="gbtree", objective="reg:linear", max.depth=5, nround=20, watchlist=watchlist,min_child_weight=10) importance_matrix <- xgb.importance(names, model = bst) xgb.plot.importance(importance_matrix[1:10,]) 

The matrix with variable significance is drawn beautifully, but when I do

 xgb.plot.tree(feature_names = names, model = bst, n_first_tree = 2) 

RStudio opens a new browser window and displays a lot of HTML, but without an image. HTML has all the details, such as the scripts needed to create graphs, etc., but I don’t have these java scripts, and I thought that this should only work as building a matrix of importance.

What am I missing?

+7
r plot xgboost
source share
1 answer

If the tree has only one node, then it will not be displayed, and this is the case for your first two trees. You can reset the tree first through xgb.dump and see which trees have more than one node, and increase the n_first_tree value n_first_tree .

0
source share

All Articles