7

I am running 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,])

Variable-importance matrix is plotted nicely but when I do following

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

RStudio opens a new browser window and shows lots of HTML, but no image. The HTML has all the details like the scripts needed to create graphs etc. but I dont have these java scripts and I was thinking it should just work like plotting the importance-matrix.

What am I missing?

smci
  • 32,567
  • 20
  • 113
  • 146
user3056186
  • 839
  • 1
  • 11
  • 16
  • Same issue for me. – joscani Apr 21 '16 at 09:04
  • I had to fix up your formatting and typos. Please use Code-formatting, not Blockquoting, on code. Also, this is not an RStudio issue, you could have tested that by rerunning just in R. – smci Mar 04 '17 at 05:37
  • Also it helps if you tell us what versions of R and xgboost: 4.4 had some known issues. – smci Mar 04 '17 at 05:48

1 Answers1

0

If a tree has only one node then it will not be plotted, and that's the case for your first two trees. You can dump your tree first via xgb.dumpand see which trees have more than one node, and increase the n_first_tree value accordingly.

ArriveW
  • 21
  • 2