decorate.xgb.Booster: Decorates an "xgb.Booster" object with "fmap", "schema",...

View source: R/decoration.R

decorate.xgb.BoosterR Documentation

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 class '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


library("xgboost")
library("r2pmml")

data(iris)
iris_X = iris[, -ncol(iris)]
iris_y = iris[, ncol(iris)]
# Convert from factor to integer[0, num_class]
iris_y = (as.integer(iris_y) - 1)
iris.matrix = model.matrix(~ . - 1, data = iris_X)
iris.DMatrix = xgb.DMatrix(iris.matrix, label = iris_y)
iris.fmap = as.fmap(iris.matrix)
iris.xgboost = xgboost(data = iris.DMatrix,
    objective = "multi:softprob", num_class = 3, nrounds = 11)
iris.xgboost = decorate(iris.xgboost, iris.fmap, 
    response_name = "Species", response_levels = c("setosa", "versicolor", "virginica"))
pmmlFile = file.path(tempdir(), "Iris-XGBoost.pmml")
r2pmml(iris.xgboost, pmmlFile, compact = FALSE)
compactPmmlFile = file.path(tempdir(), "Iris-XGBoost-compact.pmml")
r2pmml(iris.xgboost, compactPmmlFile, compact = TRUE)


r2pmml documentation built on April 6, 2023, 1:12 a.m.