[R] xgb.plot.tree fixes (#1939)

* [R] a few fixes and improvements to xgb.plot.tree

* [R] deprecate n_first_tree replace with trees; fix types in xgb.model.dt.tree
This commit is contained in:
Vadim Khotilovich
2017-01-06 13:09:51 -06:00
committed by Tianqi Chen
parent d23ea5ca7d
commit d7406e07f3
7 changed files with 225 additions and 116 deletions

View File

@@ -5,7 +5,7 @@
\title{Parse a boosted tree model text dump}
\usage{
xgb.model.dt.tree(feature_names = NULL, model = NULL, text = NULL,
n_first_tree = NULL)
trees = NULL, ...)
}
\arguments{
\item{feature_names}{character vector of feature names. If the model already
@@ -16,8 +16,13 @@ contains feature names, this argument should be \code{NULL} (default value)}
\item{text}{\code{character} vector previously generated by the \code{xgb.dump}
function (where parameter \code{with_stats = TRUE} should have been set).}
\item{n_first_tree}{limit the parsing to the \code{n} first trees.
If set to \code{NULL}, all trees of the model are parsed.}
\item{trees}{an integer vector of tree indices that should be parsed.
If set to \code{NULL}, all trees of the model are parsed.
It could be useful, e.g., in multiclass classification to get only
the trees of one certain class. IMPORTANT: the tree index in xgboost model
is zero-based (e.g., use \code{trees = 0:4} for first 5 trees).}
\item{...}{currently not used.}
}
\value{
A \code{data.table} with detailed information about model trees' nodes.
@@ -25,9 +30,9 @@ A \code{data.table} with detailed information about model trees' nodes.
The columns of the \code{data.table} are:
\itemize{
\item \code{Tree}: ID of a tree in a model
\item \code{Node}: ID of a node in a tree
\item \code{ID}: unique identifier of a node in a model
\item \code{Tree}: ID of a tree in a model (integer)
\item \code{Node}: integer ID of a node in a tree (integer)
\item \code{ID}: identifier of a node in a model (character)
\item \code{Feature}: for a branch node, it's a feature id or name (when available);
for a leaf note, it simply labels it as \code{'Leaf'}
\item \code{Split}: location of the split for a branch node (split condition is always "less than")