XGB2List | R Documentation |
Transform an xgboost object to a list of trees
XGB2List(xgb, X)
xgb |
xgboost object |
X |
predictor variable matrix |
a list of trees in an inTrees-required format
XGB2List
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.