Learn R Programming

r2pmml (version 0.31.0)

decorate.xgb.Booster: Decorates an "xgb.Booster" object with "fmap", "schema", "ntreelimit" and "pmml_options" elements.

Description

Decorates an "xgb.Booster" object with "fmap", "schema", "ntreelimit" and "pmml_options" elements.

Usage

# S3 method for xgb.Booster
decorate(
  x,
  fmap,
  response_name = NULL,
  response_levels = c(),
  missing = NULL,
  ntreelimit = NULL,
  compact = FALSE,
  ...
)

Arguments

x

An "xgb.Booster" object.

fmap

An XGBoost feature map as a "data.frame" object.

response_name

The name of the target field.

response_levels

A list of category values for a categorical target field.

missing

The string representation of missing input field values.

ntreelimit

The number of decision trees (aka boosting rounds) to convert.

compact

A flag controlling if decision trees should be transformed from binary splits (FALSE) to multi-way splits (TRUE) representation.

...

Arguments to pass on to the "decorate.default" function.

Examples

Run this code
# \donttest{
library("xgboost")
library("r2pmml")

data(iris)
iris_X = iris[, -ncol(iris)]
iris_y = iris[, ncol(iris)]
iris.fmap = as.fmap(iris_X)
iris.xgboost = xgboost(
  x = iris_X, y = iris_y,
  objective = "multi:softprob",
  nrounds = 11
)
# Please uncomment the next two lines
#iris.xgboost = decorate(iris.xgboost, iris.fmap, 
#    response_name = "Species", response_levels = c("setosa", "versicolor", "virginica"))
pmmlFile = file.path(tempdir(), "Iris-XGBoost.pmml")
# Please uncomment the next line
#r2pmml(iris.xgboost, pmmlFile, compact = FALSE)
compactPmmlFile = file.path(tempdir(), "Iris-XGBoost-compact.pmml")
# Please uncomment the next line
#r2pmml(iris.xgboost, compactPmmlFile, compact = TRUE)
# }

Run the code above in your browser using DataLab