XGB2List {inTrees} | R Documentation |
Transform an xgboost object to a list of trees
Description
Transform an xgboost object to a list of trees
Usage
XGB2List(xgb, X)
Arguments
xgb |
xgboost object |
X |
predictor variable matrix |
Value
a list of trees in an inTrees-required format
See Also
Examples
library(data.table)
library(xgboost)
# test data set 1: iris
X <- within(iris,rm("Species")); Y <- iris[,"Species"]
X <- within(iris,rm("Species")); Y <- iris[,"Species"]
model_mat <- model.matrix(~. -1, data=X)
xgb <- xgboost(model_mat, label = as.numeric(Y) - 1, nrounds = 20,
objective = "multi:softprob", num_class = 3 )
tree_list <- XGB2List(xgb,model_mat)
[Package inTrees version 1.4 Index]