从已为直方图方法(tree_method = "hist")进行量化的 xgb.DMatrix 中获取分位数切点(也称为边界)。
这些切点用于将观测值分配到 bin 中——也就是说,这些是有序的边界,用于确定分配条件 border_low < x < border_high。因此,第一个和最后一个 bin 将超出数据范围,以便包含所有观测值。
如果给定列有“n”个 bin,那么该列将有“n+1”个切点/边界,它们将按从低到高的排序顺序输出。
不同的列可以根据其范围具有不同数量的 bin。
用法
xgb.get.DMatrix.qcut(dmat, output = c("list", "arrays"))参数
- dmat
- 一个 - xgb.DMatrix对象,由- xgb.DMatrix()返回。
- output
- 分位数切点的输出格式。可能的选项有 - "list" - 将以列表形式返回输出,每个列一个条目,其中每个列将有一个包含切点的数值向量。如果dmat` 已分配列名,则该列表将被命名。
- "arrays"将返回一个包含- indptr(基于 0 索引)和- data条目的列表。在此,列“i”的切点是通过从- data中切片- indptr[i]+1到- indptr[i+1]的条目获得的。
 
示例
data(mtcars)
y <- mtcars$mpg
x <- as.matrix(mtcars[, -1])
dm <- xgb.DMatrix(x, label = y, nthread = 1)
# DMatrix is not quantized right away, but will be once a hist model is generated
model <- xgb.train(
  data = dm,
  params = xgb.params(tree_method = "hist", max_bin = 8, nthread = 1),
  nrounds = 3
)
# Now can get the quantile cuts
xgb.get.DMatrix.qcut(dm)