Get or set information of xgb.DMatrix and xgb.Booster objects
Source:R/xgb.Booster.R
, R/xgb.DMatrix.R
getinfo.Rd
Get or set information of xgb.DMatrix and xgb.Booster objects
Usage
# S3 method for class 'xgb.Booster'
getinfo(object, name)
# S3 method for class 'xgb.Booster'
setinfo(object, name, info)
getinfo(object, name)
# S3 method for class 'xgb.DMatrix'
getinfo(object, name)
setinfo(object, name, info)
# S3 method for class 'xgb.DMatrix'
setinfo(object, name, info)
Value
For getinfo()
, will return the requested field. For setinfo()
,
will always return value TRUE
if it succeeds.
Details
The name
field can be one of the following for xgb.DMatrix
:
label
weight
base_margin
label_lower_bound
label_upper_bound
group
feature_type
feature_name
nrow
See the documentation for xgb.DMatrix()
for more information about these fields.
For xgb.Booster
, can be one of the following:
feature_type
feature_name
Note that, while 'qid' cannot be retrieved, it is possible to get the equivalent 'group' for a DMatrix that had 'qid' assigned.
Important: when calling setinfo()
, the objects are modified in-place. See
xgb.copy.Booster()
for an idea of this in-place assignment works.
See the documentation for xgb.DMatrix()
for possible fields that can be set
(which correspond to arguments in that function).
Note that the following fields are allowed in the construction of an xgb.DMatrix
but are not allowed here:
data
missing
silent
nthread
Examples
data(agaricus.train, package = "xgboost")
dtrain <- with(agaricus.train, xgb.DMatrix(data, label = label, nthread = 2))
labels <- getinfo(dtrain, "label")
setinfo(dtrain, "label", 1 - labels)
labels2 <- getinfo(dtrain, "label")
stopifnot(all(labels2 == 1 - labels))
data(agaricus.train, package = "xgboost")
dtrain <- with(agaricus.train, xgb.DMatrix(data, label = label, nthread = 2))
labels <- getinfo(dtrain, "label")
setinfo(dtrain, "label", 1 - labels)
labels2 <- getinfo(dtrain, "label")
stopifnot(all.equal(labels2, 1 - labels))