Plotting tree in XGBoost


#1

Hi,
I am trying to plot a tree using xgb.plot.tree and I get the following error:

Error in seq_len(ncol(xtr)) : argument must be coercible to non-negative integer

my code is as follows:
importance_matrix <- xgb.importance(model = xgboost_model)
xgb.plot.importance(importance_matrix, measure = “Frequency”)
xgb.plot.tree(model = xgboost_model_test,
trees = 0,
show_node_id = TRUE)

I have google the error and checked stack overflow. I found one post on SO asking a similar question but there were no responses. I also looked over the code for the function in XGBoost repository but I could not find any clues on how to address. Does anyone have an idea what is causing this error.
Thanks,
Glenn


#2

I ended up shutting down R and restarting the R Studio and the plotting function works now. So, not sure what happened but if you have this problem in R try restarting it worked for me.