跳到内容

将模型参数作为 JSON 字符串的访问器

用法

xgb.config(object)

xgb.config(object) <- value

参数

object

类型为 xgb.Booster 的对象。对其赋值时将原地修改

value

一个列表。

返回值

参数以列表形式返回。

详情

请注意,赋值是在 booster 的 C 对象上原地执行的,这与 R 属性的赋值不同,不遵循典型的写时复制(copy-on-write)赋值语义 - 即对同一 booster 的所有引用也会被更新。

参阅 xgb.copy.Booster() 查看此行为的示例。

示例

data(agaricus.train, package = "xgboost")

## Keep the number of threads to 1 for examples
nthread <- 1
data.table::setDTthreads(nthread)
train <- agaricus.train

bst <- xgb.train(
  data = xgb.DMatrix(train$data, label = train$label, nthread = 1),
  nrounds = 2,
  params = xgb.params(
    max_depth = 2,
    nthread = nthread,
    objective = "binary:logistic"
  )
)

config <- xgb.config(bst)