| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/xgb.DMatrix.R |
| 3 |
\name{xgb.get.DMatrix.qcut} |
| 4 |
\alias{xgb.get.DMatrix.qcut} |
| 5 |
\title{Get Quantile Cuts from DMatrix} |
| 6 |
\usage{ |
| 7 |
xgb.get.DMatrix.qcut(dmat, output = c("list", "arrays")) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{dmat}{An \code{xgb.DMatrix} object, as returned by \code{\link[=xgb.DMatrix]{xgb.DMatrix()}}.} |
| 11 |
|
| 12 |
\item{output}{Output format for the quantile cuts. Possible options are: |
| 13 |
\itemize{ |
| 14 |
\item "list"\verb{will return the output as a list with one entry per column, where each column will have a numeric vector with the cuts. The list will be named if}dmat` has column names assigned to it. |
| 15 |
\item \code{"arrays"} will return a list with entries \code{indptr} (base-0 indexing) and |
| 16 |
\code{data}. Here, the cuts for column 'i' are obtained by slicing 'data' from entries |
| 17 |
\code{ indptr[i]+1} to \code{indptr[i+1]}. |
| 18 |
}} |
| 19 |
} |
| 20 |
\value{ |
| 21 |
The quantile cuts, in the format specified by parameter \code{output}. |
| 22 |
} |
| 23 |
\description{ |
| 24 |
Get the quantile cuts (a.k.a. borders) from an \code{xgb.DMatrix} |
| 25 |
that has been quantized for the histogram method (\code{tree_method = "hist"}). |
| 26 |
|
| 27 |
These cuts are used in order to assign observations to bins - i.e. these are ordered |
| 28 |
boundaries which are used to determine assignment condition \verb{border_low < x < border_high}. |
| 29 |
As such, the first and last bin will be outside of the range of the data, so as to include |
| 30 |
all of the observations there. |
| 31 |
|
| 32 |
If a given column has 'n' bins, then there will be 'n+1' cuts / borders for that column, |
| 33 |
which will be output in sorted order from lowest to highest. |
| 34 |
|
| 35 |
Different columns can have different numbers of bins according to their range. |
| 36 |
} |
| 37 |
\examples{ |
| 38 |
data(mtcars) |
| 39 |
|
| 40 |
y <- mtcars$mpg |
| 41 |
x <- as.matrix(mtcars[, -1]) |
| 42 |
dm <- xgb.DMatrix(x, label = y, nthread = 1) |
| 43 |
|
| 44 |
# DMatrix is not quantized right away, but will be once a hist model is generated |
| 45 |
model <- xgb.train( |
| 46 |
data = dm, |
| 47 |
params = xgb.params(tree_method = "hist", max_bin = 8, nthread = 1), |
| 48 |
nrounds = 3 |
| 49 |
) |
| 50 |
|
| 51 |
# Now can get the quantile cuts |
| 52 |
xgb.get.DMatrix.qcut(dm) |
| 53 |
} |