[R] maintenance Apr 2017 (#2237)
* [R] make sure things work for a single split model; fixes #2191 * [R] add option use_int_id to xgb.model.dt.tree * [R] add example of exporting tree plot to a file * [R] set save_period = NULL as default in xgboost() to be the same as in xgb.train; fixes #2182 * [R] it's a good practice after CRAN releases to bump up package version in dev * [R] allow xgb.DMatrix construction from integer dense matrices * [R] xgb.DMatrix: silent parameter; improve documentation * [R] xgb.model.dt.tree code style changes * [R] update NEWS with parameter changes * [R] code safety & style; handle non-strict matrix and inherited classes of input and model; fixes #2242 * [R] change to x.y.z.p R-package versioning scheme and set version to 0.6.4.3 * [R] add an R package versioning section to the contributors guide * [R] R-package/README.md: clean up the redundant old installation instructions, link the contributors guide
This commit is contained in:
committed by
Tong He
parent
d769b6bcb5
commit
a375ad2822
@@ -24,7 +24,7 @@ IMPORTANT: the tree index in xgboost model is zero-based
|
||||
|
||||
\item{render}{a logical flag for whether the graph should be rendered (see Value).}
|
||||
|
||||
\item{show_node_id}{a logical flag for whether to include node id's in the graph.}
|
||||
\item{show_node_id}{a logical flag for whether to show node id's in the graph.}
|
||||
|
||||
\item{...}{currently not used.}
|
||||
}
|
||||
@@ -68,9 +68,17 @@ data(agaricus.train, package='xgboost')
|
||||
bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_depth = 3,
|
||||
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
|
||||
# plot all the trees
|
||||
xgb.plot.tree(feature_names = colnames(agaricus.train$data), model = bst)
|
||||
# plot only the first tree and include the node ID:
|
||||
xgb.plot.tree(feature_names = colnames(agaricus.train$data), model = bst,
|
||||
trees = 0, show_node_id = TRUE)
|
||||
xgb.plot.tree(model = bst)
|
||||
# plot only the first tree and display the node ID:
|
||||
xgb.plot.tree(model = bst, trees = 0, show_node_id = TRUE)
|
||||
|
||||
\dontrun{
|
||||
# Below is an example of how to save this plot to a file.
|
||||
# Note that for `export_graph` to work, the DiagrammeRsvg and rsvg packages must also be installed.
|
||||
library(DiagrammeR)
|
||||
gr <- xgb.plot.tree(model=bst, trees=0:1, render=FALSE)
|
||||
export_graph(gr, 'tree.pdf', width=1500, height=1900)
|
||||
export_graph(gr, 'tree.png', width=1500, height=1900)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user