Debian Codegraph @

man/xgb.slice.DMatrix.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/xgb.DMatrix.R
3 \name{xgb.slice.DMatrix}
4 \alias{xgb.slice.DMatrix}
5 \alias{[.xgb.DMatrix}
6 \title{Slice DMatrix}
7 \usage{
8 xgb.slice.DMatrix(object, idxset, allow_groups = FALSE)
9
10 \method{[}{xgb.DMatrix}(object, idxset, colset = NULL)
11 }
12 \arguments{
13 \item{object}{Object of class \code{xgb.DMatrix}.}
14
15 \item{idxset}{An integer vector of indices of rows needed (base-1 indexing).}
16
17 \item{allow_groups}{Whether to allow slicing an \code{xgb.DMatrix} with \code{group} (or
18 equivalently \code{qid}) field. Note that in such case, the result will not have
19 the groups anymore - they need to be set manually through \code{\link[=setinfo]{setinfo()}}.}
20
21 \item{colset}{Currently not used (columns subsetting is not available).}
22 }
23 \description{
24 Get a new DMatrix containing the specified rows of original xgb.DMatrix object.
25 }
26 \examples{
27 data(agaricus.train, package = "xgboost")
28
29 dtrain <- with(agaricus.train, xgb.DMatrix(data, label = label, nthread = 2))
30
31 dsub <- xgb.slice.DMatrix(dtrain, 1:42)
32 labels1 <- getinfo(dsub, "label")
33
34 dsub <- dtrain[1:42, ]
35 labels2 <- getinfo(dsub, "label")
36 all.equal(labels1, labels2)
37
38 }