Skip to contents

Plot XGBoost tree visualization

Usage

tl_plot_xgboost_tree(model, tree_index = 0, ...)

Arguments

model

A tidylearn XGBoost model object

tree_index

Index of the tree to plot (default: 0, first tree)

...

Additional arguments

Value

The return value of xgb.plot.tree, a tree diagram rendered via the DiagrammeR package.

Examples

# \donttest{
if (requireNamespace("xgboost", quietly = TRUE) &&
    requireNamespace("DiagrammeR", quietly = TRUE)) {
  model <- tl_model(iris, Species ~ ., method = "xgboost", nrounds = 10)

  # tree_index is zero-based, so this is the first tree
  tl_plot_xgboost_tree(model, tree_index = 0)
}
#> Warning: Passed unrecognized parameters: tree_index. This warning will become an error in a future version.
# }