xgb.plot.tree {xgboost}R Documentation

Plot a boosted tree model

Description

Read a tree model text dump and plot the model.

Usage

xgb.plot.tree(feature_names = NULL, model = NULL, n_first_tree = NULL,
  plot_width = NULL, plot_height = NULL, ...)

Arguments

feature_names

names of each feature as a character vector. Can be extracted from a sparse matrix (see example). If model dump already contains feature names, this argument should be NULL.

model

generated by the xgb.train function. Avoid the creation of a dump file.

n_first_tree

limit the plot to the n first trees. If NULL, all trees of the model are plotted. Performance can be low for huge models.

plot_width

the width of the diagram in pixels.

plot_height

the height of the diagram in pixels.

...

currently not used.

Details

The content of each node is organised that way:

The function uses GraphViz library for that purpose.

Value

A DiagrammeR of the model.

Examples

data(agaricus.train, package='xgboost')

bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 2, 
               eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")

xgb.plot.tree(feature_names = colnames(agaricus.train$data), model = bst)


[Package xgboost version 0.6-0 Index]