inTrees (version 1.2)

XGB2List: 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

XGB2List

Examples

Run this code
# NOT RUN {
	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)
# }

Run the code above in your browser using DataCamp Workspace