I was reading a xgb notebook and the xgb.plot.tree command in example result in a pic like this:
However when i do the same thing I got a pic like this which are two separate graphs and in different colors too.
Is that normal? are the two graphs two trees?
I have the same issue. According to an issue case on the xgboost github repository, this could be due to a change in the DiagrammeR library used by xgboost for rendering trees. https://github.com/dmlc/xgboost/issues/2640
Instead of modifying the
dgr_graph
object with diagrammeR commands, I chose to create a new version of the functionxgb.plot.tree
that defines the color of font of nodes directly. It was sufficient to add the parameterfontcolor="black"
in thenodes <- DiagrammeR::create_node_df
lineThen, it remains to change some parameters to improve the readibility of the graph. Below I add an example of the code I use to display the first tree of my xgboost model.