| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/xgb.Booster.R, R/xgb.DMatrix.R |
| 3 |
\name{getinfo.xgb.Booster} |
| 4 |
\alias{getinfo.xgb.Booster} |
| 5 |
\alias{setinfo.xgb.Booster} |
| 6 |
\alias{getinfo} |
| 7 |
\alias{getinfo.xgb.DMatrix} |
| 8 |
\alias{setinfo} |
| 9 |
\alias{setinfo.xgb.DMatrix} |
| 10 |
\title{Get or set information of xgb.DMatrix and xgb.Booster objects} |
| 11 |
\usage{ |
| 12 |
\method{getinfo}{xgb.Booster}(object, name) |
| 13 |
|
| 14 |
\method{setinfo}{xgb.Booster}(object, name, info) |
| 15 |
|
| 16 |
getinfo(object, name) |
| 17 |
|
| 18 |
\method{getinfo}{xgb.DMatrix}(object, name) |
| 19 |
|
| 20 |
setinfo(object, name, info) |
| 21 |
|
| 22 |
\method{setinfo}{xgb.DMatrix}(object, name, info) |
| 23 |
} |
| 24 |
\arguments{ |
| 25 |
\item{object}{Object of class \code{xgb.DMatrix} or \code{xgb.Booster}.} |
| 26 |
|
| 27 |
\item{name}{The name of the information field to get (see details).} |
| 28 |
|
| 29 |
\item{info}{The specific field of information to set.} |
| 30 |
} |
| 31 |
\value{ |
| 32 |
For \code{getinfo()}, will return the requested field. For \code{setinfo()}, |
| 33 |
will always return value \code{TRUE} if it succeeds. |
| 34 |
} |
| 35 |
\description{ |
| 36 |
Get or set information of xgb.DMatrix and xgb.Booster objects |
| 37 |
} |
| 38 |
\details{ |
| 39 |
The \code{name} field can be one of the following for \code{xgb.DMatrix}: |
| 40 |
\itemize{ |
| 41 |
\item label |
| 42 |
\item weight |
| 43 |
\item base_margin |
| 44 |
\item label_lower_bound |
| 45 |
\item label_upper_bound |
| 46 |
\item group |
| 47 |
\item feature_type |
| 48 |
\item feature_name |
| 49 |
\item nrow |
| 50 |
} |
| 51 |
|
| 52 |
See the documentation for \code{\link[=xgb.DMatrix]{xgb.DMatrix()}} for more information about these fields. |
| 53 |
|
| 54 |
For \code{xgb.Booster}, can be one of the following: |
| 55 |
\itemize{ |
| 56 |
\item \code{feature_type} |
| 57 |
\item \code{feature_name} |
| 58 |
} |
| 59 |
|
| 60 |
Note that, while 'qid' cannot be retrieved, it is possible to get the equivalent 'group' |
| 61 |
for a DMatrix that had 'qid' assigned. |
| 62 |
|
| 63 |
\strong{Important}: when calling \code{\link[=setinfo]{setinfo()}}, the objects are modified in-place. See |
| 64 |
\code{\link[=xgb.copy.Booster]{xgb.copy.Booster()}} for an idea of this in-place assignment works. |
| 65 |
|
| 66 |
See the documentation for \code{\link[=xgb.DMatrix]{xgb.DMatrix()}} for possible fields that can be set |
| 67 |
(which correspond to arguments in that function). |
| 68 |
|
| 69 |
Note that the following fields are allowed in the construction of an \code{xgb.DMatrix} |
| 70 |
but \strong{are not} allowed here: |
| 71 |
\itemize{ |
| 72 |
\item data |
| 73 |
\item missing |
| 74 |
\item silent |
| 75 |
\item nthread |
| 76 |
} |
| 77 |
} |
| 78 |
\examples{ |
| 79 |
data(agaricus.train, package = "xgboost") |
| 80 |
|
| 81 |
dtrain <- with(agaricus.train, xgb.DMatrix(data, label = label, nthread = 2)) |
| 82 |
|
| 83 |
labels <- getinfo(dtrain, "label") |
| 84 |
setinfo(dtrain, "label", 1 - labels) |
| 85 |
|
| 86 |
labels2 <- getinfo(dtrain, "label") |
| 87 |
stopifnot(all(labels2 == 1 - labels)) |
| 88 |
data(agaricus.train, package = "xgboost") |
| 89 |
|
| 90 |
dtrain <- with(agaricus.train, xgb.DMatrix(data, label = label, nthread = 2)) |
| 91 |
|
| 92 |
labels <- getinfo(dtrain, "label") |
| 93 |
setinfo(dtrain, "label", 1 - labels) |
| 94 |
|
| 95 |
labels2 <- getinfo(dtrain, "label") |
| 96 |
stopifnot(all.equal(labels2, 1 - labels)) |
| 97 |
} |